CodeCoupler UI DataSource Mixin "Validate"
Part of the
CodeCoupler UI Pro package.
For now only the validation rule
required will be used! All other rules will be supported in
The model allow you to define validation mechanisms in the field configuration property
These validations are intended for data entry. So you can catch invalid inputs and do not even try to send them to the server. The origin datasource do not use these validations when syncing to the server. If you set an invalid value in a data item and you try to sync the datasource will send this invalid data to the server (where these will hopefully be rejected).
This mixin use the validation definitions when calling
sync(). In case of an validation error the
invalid values will not be send to the server. This has the advantage that not only user inputs are
validated in a single step, but also data changes that are made programmatically.
In case of a validation error the following is carried out:
changeevent followed by an
errorevent a special error object will be triggered.
- The promise of the
syncmethod will be rejected with the same error object.
The error object that will be returned in the
error event is:
1 2 3
arrayOfFailedDataItems include all data items of the datasource which do not pass. In every of
these data items a property
validationResults exists with the following structure:
1 2 3 4 5
Read more about the error message and how to modify them here: [https://docs.telerik.com/kendo-ui/controls/editors/validator/rules#custom-messages]
Normally the fieldname will be used in an error message. But you can define a special field
visual.name. If defined this name will be used.
The datasource extended with this mixin provides two new methods:
Validate all data items in the datasource. Returns an array with dataitems with validation errors. If no errors exists the array is emtpy.
Validate a dataitem. A new property
validationResultswill be added to the dataitem. You can check with
validationResults.passif a validation error occured.