In C#, attribute parameters require to be a constant expression, typeof or array creation expression.
Various libraries, like for example Castle validator, allow specifying passing what seems like localized error messages to attribute constructor:
//this works
[ValidateNonEmpty("Can not be empty")]
//this does not compile
[ValidateNonEmpty(Resources.NonEmptyValidationMessage)]
Is there any way how to approach this problem and localize these arguments?
In case there is no workaround for this when using Castle Validator, is there a validation library similar to Castle Validator that allows localization of validation messages?
EDIT: I found how Data Annotations validation library approaches this problem. Very elegant solution: http://haacked.com/archive/2009/12/07/localizing-aspnetmvc-validation.aspx