FailureValidationResult
Description
A FailureValidationResult
is an interface that exposes the result of a failure validation of a datacell
’s edited content.
Properties
Property |
Type |
Description |
---|---|---|
errorMessage |
any |
The validation error message. |
isValid |
boolean |
false to indicate that the validation failed. |
Example
The validateGreaterZero
function receives a ValidationContext
parameter and returns a FailureValidationResult
when the dataCell
’s edited value (retrieved from ValidationContext
.newValue
) is smaller than zero.
function validateGreaterZero(validationContext)
{
if (validationContext.newValue < 0)
{
return {
isValid: false,
errorMessage: “integer value must be greater than 0”
};
}
return { isValid: true };
}
The validateGreaterZero
function should be set as a ValidationRuleDefinition
.validate
function. This ValidationRuleDefinition
should be set in the DataGridOptions
.validationRuleDefinitions
as a value. The key of this value should be used as the identifier on each of the columns needing this validationRule
on the ColumnDefinition
.validationRules
property.