Question

According to the NHibernate Validator documentation here:

http://nhforge.org/wikis/validator/nhibernate-validator-1-0-0-documentation.aspx

I should be able to pass my resource manager so I can use that for validation error messages. See:

Alternatively you can provide a ResourceManager while checking programmatically the validation rules...

And:

If NHibernate Validator cannot resolve a key from your ResourceManager nor from ValidatorMessage, it falls back to the default built-in values.

It even shows and example of doing just this in an attribute on a entity property:

 // a not null numeric string of 5 characters maximum
    // if the string is longer, the message will
    // be searched in the resource bundle at key 'long'
    [Length(Max = 5, Message = "{long}")]
    [Pattern(Regex = "[0-9]+")]
    [NotNull]
    public string Zip
    {

        get { return zip; }
        set { zip = value; }
    }

However, as far as I can see it doesn't specify how you pass the resource manager to the validation framework - does anyone know how to do this?

Thanks!

Was it helpful?

Solution

Have a look at this post and answers to this SO question (it describes some gotchas in using message interpolator).

Hope this will help you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top