Skip to content

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
Rules:
- Type: IsNotNull


IsNull

Opposite of the IsNotNull type. Ensures that the specified property value is null.

Example:

1
2
Rules:
- Type: IsNull


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
Rules:
- Type: IsNotEmpty


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
Rules:
- Type: IsEmpty


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
Rules:
- Type: IsNotEqual
  Expressions:
  - Value(@ConstInt::10) # Expression to get the number (Int32) 10 as constant


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
Rules:
- Type: IsEqual
  Expressions:
  - Value(@UtcToday) # Expression to get the current date


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
Rules:
- Type: IsGreaterThan
  Expressions:
  - Value(@ConstShort::50) # Expression to get the number (Int16) 50 as constant


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
Rules:
- Type: IsGreaterThanOrEqual
  Expressions:
  - Value(@ConstShort::50) # Expression to get the number (Int16) 50 as constant


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
Rules:
- Type: IsLessThan
  Expressions:
  - Value(@ConstLong::1000) # Expression to get the number (Int64) 1000 as constant


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
Rules:
- Type: IsLessThanOrEqual
  Expressions:
  - Value(@ConstLong::1000) # Expression to get the number (Int64) 1000 as constant


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
Rules:
- Type: IsBetween
  Expressions:
  - Value(@ConstInt::1)
  - Value(@ConstInt::10)


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
Rules:
- Type: IsLengthBetween
  Expressions:
  - Value(@ConstShort::1)
  - Value(@ConstShort::50)


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
Rules:
- Type: IsMatchesTo
  Expressions:
  - Value(@Regex::XltBLVpdJA==) # Expression to get a Regular Expression (Expression argument in this sample evaluates to '^A-Z$')

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
Rules:
- Type: IsCreditCard


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
Rules:
- Type: IsEmailAddress


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
Rules:
- Type: IsCpf


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
Rules:
- Type: IsCnpj


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
Rules:
- Type: IsValidation
  Expressions:
  - ValInstance(@ConstString::My_Second_EntityValidation) # Expression to get the validation object instance


Back to top