This topic illustrates on how to extend ValidationAttribute and create custom validations to meet specific requirements.
- RequiredIf Validator Requirement: Address.City is required when Address.Country's value is "USA".
- RequiredIfNot Validator Requirement: Address.City is required when Address.Action is not "DELETE".
- RequiredIf Dependent Field IsNull Validator Requirement: Address.Country is required when Address.City value is not provided OR NULL.
- RequiredIf Dependent Field IsNotNull Validator Requirement: Address.Country is required when Address.City value is not NULL.
- RequiredEither Field Validator Requirement: Contact.Phone or Contact.Email is required.
- RequiredIfRegEx Dependent Field Is Validator Requirement: Address.Phone should be between 0-9 numbers when Address.City value equals some value ex: USA.
- RequiredIfNotRegEx Dependent Field IsNot Validator Requirement: Address.Phone should be between 0-9 numbers when Address.City value not equals some value ex: USA.
No comments:
Post a Comment