Closed michalczerwinski closed 7 months ago
When using custom ValidationAttribute it is only possible to access property value. This makes impossible creating validation which relies on multiple fields.
Potential solutions:
- Add root object into items dictionary in ValidationContext:
new ValidationContext(value, new Dictionary<object, object> { {"root", component} }) { DisplayName = property.DisplayName, MemberName = property.Name },
- Extending ValidatorUtils.TryValidateObject to support IValidatableObject interface.
I can prepare pull request if you would be willing to accept it. What do you think?
My initial idea is that if you rely on multiple conditions, you can add a separate attribute specifically to support this situation, as long as this attribute is invisible to the control. There are also some logical problems when supporting multiple conditions, such as are these conditions and or or?
I very much welcome all kinds of pull requests. After all, a person's energy and knowledge are limited, as long as it can run correctly. grateful.
When using custom ValidationAttribute it is only possible to access property value. This makes impossible creating validation which relies on multiple fields.
Potential solutions:
I can prepare pull request if you would be willing to accept it. What do you think?