equalTo
Validates that the object value is equal to the expected value.
This function creates a validation rule that checks if the current object value equals the value returned by the expected function using the ==
operator. The comparison is performed each time the validation runs, allowing for dynamic expected values.
Usage:
// Password confirmation validation
rules<String> {
equalTo({ passwordField.value }) { "Password confirmation must match the password" }
}
Content copied to clipboard
Parameters
V
The type of the object value being validated. Must be a non-null type.
expected
A function that returns the expected value to compare against. This is called each time validation runs, enabling dynamic comparisons.
message
A function that returns the error message when validation fails. This is only called when the validation actually fails.