Msdn:
public static readonly ValidationResult ValidationResult.Success
Represents the success of the validation (true if validation was successful; otherwise, false).
The text in above excerpt doesn't make sense to me, since Success
field doesn't return a value of type bool
, and the value it does return ( ie ValidationResult
instance ) doesn't contain any boolean property or field which we could set to a value indicating a success or failure of a validation?!
Any ideas what is the purpose of this field?
ValidationResult(String, IEnumerable<String>) Initializes a new instance of the ValidationResult class by using an error message and a list of members that have validation errors. ValidationResult(ValidationResult) Initializes a new instance of the ValidationResult class by using a ValidationResult object.
This class describes the type or member on which validation is performed. It also enables custom validation to be added through any service that implements the IServiceProvider interface.
Validates that a property value matches a specified regular expression. Built-in. Remote. Performs a remote validation: you call an action method on the server to validate inputs on the client.
ValidationResult.Success
is always constant null
. Its purpose is documentation.
In order to succeed validation you could either write:
return null;
or
return ValidationResult.Success;
In the first case I ask myself "What does this mean? What does null mean? Is this success, or fail, or something else?". In the latter case the code is inherently documented without the need for informal text docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With