Allowed PropertyValidation Rule Types
Entity property validations have several types of pre-defined rules. Below, find out about the existing types, as well as the appropriate usage rules for each one.
IsNotNull
Ensures that the specified property value is not null.
Example:
1 2 |
|
IsNull
Opposite of the IsNotNull type. Ensures that the specified property value is null.
Example:
1 2 |
|
IsNotEmpty
Ensures that the specified property value is not null, an empty string, whitespace or the default value for the property type.
Example:
1 2 |
|
IsEmpty
Opposite of the IsNotEmpty type. Ensures that the specified property value is null or is the default value for the property type.
Example:
1 2 |
|
IsNotEqual
Ensures that the specified property value is not equal to a certain value.
Requirements Rules:
- Is required one Expression with the value for comparison;
- The value returned by Expression must be the same type as the property
Example:
1 2 3 4 |
|
IsEqual
Opposite of the IsNotEqual type. Ensures that the specified property value is equal to a certain value.
Requirements Rules:
- Is required one Expression with the value for comparison;
- The value returned by Expression must be the same type as the property
Example:
1 2 3 4 |
|
IsGreaterThan
Ensures that the specified property value is greater than a certain value.
Requirements Rules:
- Is required one Expression with the value for comparison;
- The value returned by Expression must be the same type as the property
Example:
1 2 3 4 |
|
IsGreaterThanOrEqual
Ensures that the specified property value is greater than or equal to a certain value.
Requirements Rules:
- Is required one Expression with the value for comparison;
- The value returned by Expression must be the same type as the property
Example:
1 2 3 4 |
|
IsLessThan
Ensures that the specified property value is less than a certain value.
Requirements Rules:
- Is required one Expression with the value for comparison;
- The value returned by Expression must be the same type as the property
Example:
1 2 3 4 |
|
IsLessThanOrEqual
Ensures that the specified property value is less than or equal to a certain value.
Requirements Rules:
- Is required one Expression with the value for comparison;
- The value returned by Expression must be the same type as the property
Example:
1 2 3 4 |
|
IsBetween
Checks whether the specified property value is in a range between the two specified values (inclusive).
Requirements Rules:
- Two Expressions are required specifying the minimum and maximum value for the range;
- Both values returned by Expressions must be the same type as the property
Example:
1 2 3 4 5 |
|
IsLengthBetween
Checks whether the length of a string property is within the specified range.
Requirements Rules:
- Two Expressions are required specifying the minimum and maximum value for the range;
- Both values returned by Expressions must be of int (Int32) or short (Int16) types;
- The specified property must be of string type
Example:
1 2 3 4 5 |
|
IsMatchesTo
Ensures that the value of the specified property matches the given regular expression.
Requirements Rules:
- Is required one Expression with the value for comparison;
- The value returned by Expression must be a valid regular expression;
- The specified property must be of string type
Example:
1 2 3 4 |
|
Important: In order to avoid YAML deserialization problems, the regular expression must be informed in Base64 format.
IsCreditCard
Checks whether the specified string property value is a valid credit card number.
Requirements Rules:
- The specified property must be of string type
Example:
1 2 |
|
IsEmailAddress
Checks whether the specified string property value is a valid email address format.
Requirements Rules:
- The specified property must be of string type
Example:
1 2 |
|
IsCpf
Checks whether the specified string property value is a valid CPF number.
Requirements Rules:
- The specified property must be of string type
Example:
1 2 |
|
IsCnpj
Checks whether the specified string property value is a valid CNPJ number.
Requirements Rules:
- The specified property must be of string type
Example:
1 2 |
|
IsValidation
Applicable for properties whose type is a relationship with another entity.
Allows you to reuse the validation object already designed for the relationship entity, avoiding all rules from being rewritten for the current property.
Requirements Rules:
- ValInstance Expression is required, containing a parameter with the name of the validation object;
- The specified property must be a relationship with the entity of the validation object;
- The name of validation object must exist in current model
Example:
1 2 3 4 |
|