Closed kvnallen closed 7 years ago
@kvnallen,
I liked your idea, but Is it possible to just inform the index and let the same method "AddNotification" to be in charge of swapping it by the parameter value?
That way we could avoid have to send new parameters. For example:
public ValidationContract HasMinLen(string val, int min, string property, string message)
{
if (val.Length < min)
AddNotification(property, string.Format(message, property, min));
return this;
}
That way, it will be similar to what we usually do in the Data Annotations:
[MinLength(10, ErrorMessage = "{0} field must be at least {1} characters in length")]
var right = new ValidationContract()
.Requires()
.HasMinLen(dummy.stringProp, 10, nameof(dummy.stringProp), "{0} field must be at least {1} characters in length");
I think is better to keep any kind of "string manipulation" out. I agree with @fgemig
Added support to use notification parameters in messages e.g: