Whether this validator also runs when the parent does not pass the property at all.
By default a constraint is checked only against a prop the element actually passes, because
most constraints describe a value ("these are field names on the entity") and have nothing to
say about a missing one. A validator whose rule is about absence — "this prop must be set",
"this prop must be set when another one is" — overrides this to return true. It is then
also called for a missing prop, with context.PropertyPresent === false and
context.propertyValue === undefined, and must handle that case.
It is still not called for a missing prop when the element spreads props
(<Grid {...props} />), since the spread may supply it.
ProtectedapplyApply custom error template
If the constraint has an errorTemplate, applies it by replacing
template variables with actual values.
Template variables:
Constraint definition
Validation context
Default message to use if no template
Additional template variables
Formatted message
ProtectedcreateCreate a violation with consistent formatting
Helper method to create ConstraintViolation objects with common fields populated.
Violation type (e.g., 'invalid-field', 'type-mismatch')
Error message
Severity level (default: 'high')
Optionalsuggestion: stringOptional fix suggestion
Optionalmetadata: Record<string, any>Optional additional metadata
ConstraintViolation object
ProtectedequalsCase-insensitive string comparison
First string
Second string
True if strings are equal (case-insensitive)
ProtectedfindFind similar strings using Levenshtein distance
Returns strings sorted by similarity (most similar first).
The target string to find matches for
Array of candidate strings
Maximum number of results (default: 3)
Maximum edit distance to consider (default: 3)
Array of similar strings, sorted by distance
ProtectedformatFormat a list of values for error messages
Truncates long lists with "..." and formats values nicely.
Array of values
Maximum items to show (default: 10)
Formatted string
ProtectedgetGet the dependent prop value
If the constraint has a dependsOn field, this method retrieves
the value of that dependent prop from sibling props.
Returns null if:
Validation context
Constraint definition
The dependent prop value, or null if not available
Get description of this validator
Use GetName.
Get the name of this validator
Used for debugging and error messages. Defaults to the class name, but can be overridden.
Validator name
ProtectedincludesCheck if array contains value (case-insensitive for strings)
Array to search
Value to find
True if array contains the value
ProtectedisCheck if a value is dynamic (can't be validated statically)
Dynamic values include identifiers (variables) and expressions (function calls, etc.) that can't be resolved at lint-time.
The extracted value to check
True if the value is dynamic
ProtectedlevenshteinCalculate Levenshtein distance between two strings
Used for finding similar field names for "Did you mean?" suggestions.
First string
Second string
Edit distance
Validate that a property is present when a condition is met
Evaluates a JavaScript condition expression with the dependent property value, and checks if the current property has a value when the condition is true.
Validation context containing property info and sibling props
The constraint definition from the spec
Array of violations (empty if valid)
Abstract base class for semantic validators
All semantic validators must extend this class and implement the validate() method.