Questions tagged [validationrules]

A validation rule is a criterion used in the process of data validation, after the data has been encoded onto an input medium. This is distinct from formal verification, where the operation of a program is determined to be correct per the specification.

A validation rule is a criterion used in the process of data validation, after the data has been encoded onto an input medium. This is distinct from formal verification, where the operation of a program is determined to be correct per the specification.

An example of a validation check is the procedure used to verify an ISBN:

  1. Size. The number of characters in a data item value is checked; for example, an ISBN must consist of 10 characters only (in the previous version – the standard for 1997 and later has been changed to 13 characters).

  2. Format checks. Data must conform to a specified format. Thus, the first 9 characters must be the digits 0 through 9, and the 10th must be either one of those digits or an X.

  3. Consistency. Codes in the data items which are related in some way can thus be checked for the consistency of their relationship. The first number of the ISBN designates the language of publication. for example, books published in French-speaking countries carry the digit "2". This must match the address of the publisher, as given elsewhere in the record.

  4. Range. Does not apply to ISBN, but typically data must lie within maximum and minimum preset values. For example, customer account numbers may be restricted within the values 10000 to 20000, if this is the arbitrary range of the numbers used for the system.

  5. Check digit. An extra digit calculated on, for example, an account number, can be used as a self-checking device. When the number is input to the computer, the validation program carries out a calculation similar to that used to generate the check digit originally and thus checks its validity. This kind of check will highlight transcription errors where two or more digits have been transposed or put in the wrong order. The 10th character of the 10-character ISBN is the check digit.

Source: Wikipedia

189 questions
30
votes
10 answers

Using WPF Validation rules and the disabling of a 'Save' button

I have a page where a few textboxes cannot be empty before clicking a Save button.
ScottG
  • 10,711
  • 25
  • 82
  • 111
18
votes
3 answers

ValidationRules without binding

I want to use the ValidationRules (and it's UI effects) on the textbox without actually binding anything to the textbox. I want to use the textbox for some input that doesn't bound to anything but need to validate the input after focus is lost…
anderi
  • 767
  • 2
  • 11
  • 18
17
votes
4 answers

Validation rules required_if with other condition (Laravel 5.4)

I got a problem with validation rules with nested conditions. class StoreRequest extends Request { public function authorize(){ return true; } public function rules(){ return [ …
kesm0
  • 847
  • 1
  • 11
  • 20
13
votes
5 answers

WPF Binding : Use DataAnnotations for ValidationRules

I have read a lot of Blog post on WPF Validation and on DataAnnotations. I was wondering if there is a clean way to use DataAnnotations as ValidationRules for my entity. So instead of having this (Source) :
Philippe Lavoie
  • 2,583
  • 5
  • 25
  • 39
10
votes
0 answers

Database Drive Rule Engine Using NRules

I am creating a business rule engine and planning to user NRules framework. https://github.com/NRules/NRules But I want to know if I can generate rule from database it self. I have a database table which has some rule saved. Age > 20 Name …
Pawan Agrawal
  • 412
  • 8
  • 26
10
votes
4 answers

In Laravel, what validation rules do I need to check the number of characters in a number?

I'm using rules in validation in Laravel, and am trying to check the number of characters in a number. This is my attempt: protected static $rules = [ 'zip_code' => 'required|size:5|integer' ]; Unfortunately that checks that the zip code is the…
zeckdude
  • 15,877
  • 43
  • 139
  • 187
9
votes
6 answers

Javascript Regex to limit Text Field to only Numbers (Must allow non-printable keys)

I have received PHP/JS code from previous developer and I need to add number validation to a Mobile Number field. I already have the HTML validation in place but I need to add that if someone presses an invalid key, that it doesn't get displayed…
RMK
  • 456
  • 2
  • 9
  • 19
9
votes
1 answer

How to get validation rules from FluentValidator

Given a validator extending AbstractValidator and implementing IValidator, I would like to get it's rules. There seems to be no way to do this?
Shumii
  • 4,529
  • 5
  • 32
  • 41
8
votes
3 answers

How to specify a validation rule in Yii2 which will be greater than or less than of a specific number or value?

I have a model with a validation rule like: [['x'], 'integer'], [['x'], 'unique'], Now how can I add a rule like: x < 100 or something like x >= 100
8
votes
3 answers

Property Binding Not Updating When ValidationRule Fails

I've got a few TextBoxes for input fields and a "Save" Button in my view. Two of the TextBoxes are required fields for saving, and I've set up a custom ValidationRule in the xaml for some visual feedback (red borders and tooltips) like so:
Nightmare Games
  • 2,205
  • 6
  • 28
  • 46
7
votes
2 answers

How to override the message of the custom validation rule in Laravel?

I am developing a Laravel application. What I am doing in my application is that I am trying to override the custom validation rule message. I have validation rules like this in the request class: [ 'name'=> [ 'required' ], 'age' => […
Wai Yan Hein
  • 13,651
  • 35
  • 180
  • 372
6
votes
5 answers

In Codeigniter, how to pass a third parameter to a callback (form validation)?

I am currently using the Form Validation class (on Codeigniter) and setting rules. It works like this with two parameters (codeigniter.com/user_guide/libraries/form_validation.html): $this->form_validation->set_rules('username', 'Username',…
Dacobah
  • 779
  • 3
  • 15
  • 35
6
votes
1 answer

What do "except" and "idColumn" refers in "unique:table,column,except,idColumn"? from Laravel docs

To validate the update of the e-mail of a user already registered I have the next function to exclude the "unique" rule for the current User: public function updateRules() { return [ 'name' => 'required', 'email' =>…
Alcides
  • 508
  • 1
  • 7
  • 15
5
votes
1 answer

ValidationRules not removing error when value is set back to valid value

INTRODUCTION I have created a DecimalTextBox UserControl that houses some decimal validation I need done, so that I dont need to recreate the validation each time, and can just use the UserControl instead. This validation has properties that need to…
Jason Ridge
  • 1,868
  • 15
  • 27
5
votes
2 answers

Validation between multiple fields in different levels

I have a problem with validations between multiple fields. For example, I have a ViewModel named RangeDateViewModel that contains 2 instances of a class named DateViewModel - they represent a start date and an end date respectively. So my binding…
Dror
  • 2,548
  • 4
  • 33
  • 51
1
2 3
12 13