开发者

NHibernate Validator - passing resource manager and key

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 Re开发者_JAVA百科sourceManager 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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜