You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now there is possibility to override validation message by use WithMessage function.
varspec= Specification.Length<string>(5).WithMessage("Incorrect value length");
spec.IsSatisfiedBy("lorem ipsum",outvar result);// "Incorrect value length"
There should be possibility to create validation message based on candidate value and specification parameters:
varspec= Specification.Length<string>(5).WithMessage((c,p)=>$"Incorrect value length - expected [{p["Length"]}] but passed [{c.Length}]");
spec.IsSatisfiedBy("lorem ipsum",outvar result);// "Incorrect value length - expected [5] but passed [11]"
Localization example:
publicIValidationSpecification<string>CreateSpecification(IStringLocalizerlocalizer){return Specification.MaxLength<string>(100).WithMessage((c,p)=> localizer.GetString("Max length of value should be {1} but passed value has {0}", c.Length, p["MaxLength"]));}
The text was updated successfully, but these errors were encountered:
Right now there is possibility to override validation message by use
WithMessage
function.There should be possibility to create validation message based on candidate value and specification parameters:
Localization example:
The text was updated successfully, but these errors were encountered: