Stores the indexes of the values that failed validation when the value property is an array.
Use @fireflysemantics/is/isArray to check whether ValidationError.value is an array.
The error messge.
The object containing the invalid property.
The name of the property containing the value that did not pass the validation check.
The value that failed the validation check.
If this is an array of values, then the ValidationError.errorIndex stores the indices of the values that did not pass validation.
Check if the value is an array using value instanceof Array
.
The validation context
Get the validation error message.
Note that the implementation here is a little strange
since we are passing in the vc
to vc.errorMessage
,
which seems redundant, but we have to do it because
the errorMessage
function comes from the decorator
and is different for each ValidationContext
instance,
since each is specific to a class and property context.
Generated using TypeDoc
There can be multiple
ValidationError
instances per object property.For example suppose we have a
name
property decorated with the theIsAlpha
annotation like this:If the
name
property violates theIsAlpha
constraint then aValidationError
instance will be created for that constraint violation. If theIsDefined
constraint is violated then a separateValidationError
instance is created for that constraint.Instances of
ValidationError
contain the:object
and the name of theobjectProperty
that was validatedvalue
being validatederrorIndex
(When the value being validated is an array)