Open sergio11 opened 7 years ago
We don't have the validator now. Maybe we need a 'CompareAttribute' such as:
//
// Summary:
// Provides an attribute that compares two properties.
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public class CompareAttribute : ValidationAttribute
{
//
// Summary:
// Initializes a new instance of the System.ComponentModel.DataAnnotations.CompareAttribute
// class.
//
// Params:
// otherProperty:
// The property to compare with the current property.
public CompareAttribute(string otherProperty);
//
// Summary:
// Gets the property to compare with the current property.
//
// Returns:
// The other property.
public string OtherProperty { get; }
//
// Summary:
// Gets the display name of the other property.
//
// Returns:
// The display name of the other property.
public string OtherPropertyDisplayName { get; }
}
Can you contribute codes about it? And I will merge it.
Is it possible to create a validator to compare the value of two fields?.
I wanted to implement a validator that compares the value of PasswordClear and ConfirmPassword.
With the Bean Validation API I have implemented a validator of this style
@FieldMatch (first = "passwordClear", second = "confirmPassword", message = "{user.pass.not.match}")
Where can I find documentation on how to implement custom validators?
Thanks in advance.