Closed dhlavaty closed 1 year ago
Cool will have to check this out, i tried getting constants working to be able to use validation attributes (like adding a regex string), but after i got it working i realized it was always getting stuck on the same language.
Will be totally awesome if you actually got that working !
Not really sure what you mean by "getting constants working", but it definitely work for me.
You can use:
[Required(ErrorMessageResourceName = Resources.User.RequiredErrorKey, ErrorMessageResourceType = typeof(Resources.User))]
instead of old version:
[Required(ErrorMessageResourceName = "RequiredError", ErrorMessageResourceType = typeof(Resources.User))]
ah i see. i was talking about being able to localize some string like
[RegularExpression("pattern")]
unfortunately pattern in this case must either be a inline
string or a constant
Found no way to get this working aside creating a custom validation attribute like
[RegularExpressionLocalized("PseudoRegex", ErrorMessageResourceName = "PseudoRegexError", ErrorMessageResourceType = typeof(Resources.Objects.User.Register))]
All resource keys are accessible by ResourceKey constants. So you can use compiler type checking for validation attributes.