Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

help me understand the method Validator.TryValidateObject()

this is the method definition:

public static bool TryValidateObject(
Object instance,
ValidationContext validationContext,
ICollection<ValidationResult> validationResults,
bool validateAllProperties

)

what i am confused is the validateAllProperties parameter, I understand when it is true-validate all properties.

What about when it is false, not validate all properties, but which property will be validated?

like image 805
Benny Avatar asked Apr 12 '26 09:04

Benny


1 Answers

See here for a good answer:

http://connect.microsoft.com/VisualStudio/feedback/details/605635/missleading-parametername-validateallproperties-in-validator-try-validate-componentemodel-dataannotations

It seems that when validateAllProperties is set to false that only the RequiredAttribute is validated.

like image 141
Arjen den Hartog Avatar answered Apr 24 '26 04:04

Arjen den Hartog



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!