Context Validations
The validations section allows you to define the business validation rules that will be applied to the current Context.
Each validation in this section is always executed in a context plus an execution order. The execution order follows the validation position at the collection of validations you created. The generated order by Beatrix is always every 10 positions (10, 20, 30...), which allows you to create new validation classes in these intervals.
Fields
A context validation contains the following fields to be defined:
Name
The name of context validation to be created.
Requirements Rules:
- Is Required;
- Must not be a Reserved Keyword;
- Must start with a letter;
- Must contains only letters, numbers and the underline char ('_');
- Max length of 50 chars
Example:
1 2 |
|
Type
The type of context validation to be created.
Possible types are:
- EntityValidation: Allows to use a Entity Validation in this context and execution order;
- BlankValidation: Creates a blank validation class, in this context and execution order, for you to place your customized validation logic, avoiding conflicts in future merges
Requirements Rules:
- Is Required;
- Must be an Allowed valid type, according to the types informed above;
- Must be Allowed for current context:
- If EntityValidation, it's allowed only following contexts: Create, Update and UpdatePartial;
- If BlankValidation, it's allowed for all available contexts
Example:
1 2 3 |
|
Order
Specifies the order in which this validation class will be performed on the validation pipeline within the current context.
Requirements Rules:
- Is Required;
- Must be in the range between 1 and 300;
- Each validation class must have its unique order for the current context
Example:
1 2 3 4 |
|
Tip: Keep a gap between the validation classes so that it is possible to add new classes between the orders already defined without having to reorder them.
ExecValidationName
The name of validation in current model that not belongs to a context and execution order, for example: EntityValidation.
This field allows you to link another validation to be performed in the current context and execution order.
Requirements Rules:
If EntityValidation type:
- Is Required;
- The name must exist in EntityValidation list in the current model
If BlankValidation type:
- Must not be filled
Example:
1 2 3 4 5 |
|
ConditionalValidationName
The name of validation in current model that not belongs to a context and execution order and that you want to use as a conditional validation.
The validation informed in this field will be performed first and, if successful, the validation defined in the field ExecValidationName will be performed.
A usage example: A date field should only be validated if it's filled. In this case, the ConditionalValidationName will be a validation that checks if the date field is filled and the ExecValidationName will be a validation that checks if the date field is a valid date.
Requirements Rules:
If EntityValidation type:
- The name must exist in EntityValidation list in the current model;
- The name must not be the same as the ExecValidationName field
If BlankValidation type:
- Must not be filled
Example:
1 2 3 4 5 6 |
|