this exists for cloning. Because the default usage is "object" based, this needs to be saved during initialization as the defaultValidationValidations do not exist on prototype in order so it could be fed to a clone.
validateDefault takes values of an object under this property and calls all of them. When you use "object flow", the validation methods in constructor will be enriched with validateProperty, and set on instance, as well their references will be set on this property
each model instance has own instance of validator. model is passed in constructor, so validator can operate on it.
is used for caching values, so if optimization is neccessary you can e.g. check, if new value is not different than old one, you can skip expensive validation logic. the last value will be added on cache in @validates decorator. if you use @validates decorator it's happening automatically if not you can do it manually
sets an error on model. if model already has same message it is ignored. errors are set on model.modelData internal object: so all error accessing methods are basically proxies that read from that internal object
property for which an error shall be set on model
error message for property
used by formState, if you provide an adhoc validation, if you do so, this validation will be added to default ones
relevant to makeFormModel flow
errors - all errors for property
because there may be multiple errors, they are contained in array, but normally you need only first one, e.g. to show in component. This returns it
returns last validated cachec value for property. Usefull if you need to skip validation.
property which value will be returned from cache
depending on result returned by validation function, handles addition/removal of errors on model
property name for which validation result is handled in question
a return result of validation function of type ValidationReturn if valid: removes all errors for property if valid and single error: adds error if not there, other errors (e.g. from other validators are not removed) above is useful when different methods validate the field, so they do not interfere with each other if valid and multiple: removes all errors, sets errors contained in result.errors above is useful when you have single method that validates property and you support multiple errors
bool - true if property has no error, false otherwise
false if any error or any nested model has any error
property for which all errors will be unset on model
property for which error shall be removed
if error with value exists for model, it will be removed
resets/unsets all errors for all properties on model
will call any methods with specified name provided in arg.
runs any validations specified in defaultValidations. for makeFormModel flow - any passed validations be called. for custome flow any referenced methods in defaultValidations
if should validateDefault on nested models' validators. Defaults to true
runs validation function, and handles it's result. behind the scenes will define if validation needs to be run by comparing cache values if validation unnecessary - skips otherwise runs validation and handles result, via adding/removing errors for property and updating cache.
property that's being validated
any function that accepts value and returns ValidationReturn. Value will be read from model's property
various options
compares value on cache and on model. true if values are same AND value was at least once validated
property to compare with cache
Generated using TypeDoc
Each FormModel has corresponding ModelValidator. Model Validator is responsible mostly for
Object flow basic usage:
custom "recommended" flow
very customized usage: nothing stands in your way, you can do whatever you want: