NHibernate Validator - transfer of resource manager and key

According to NHibernate Validator documentation:

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

I need to pass the resource manager so that I can use this for validation error messages. Cm:

Alternatively, you can provide a ResourceManager by checking programmatically validation rules ...

and

If the NHibernate Validator cannot resolve the key from the ResourceManager or from the ValidatorMessage, it will revert to the built-in default values.

It even shows an example of how this is done in the attribute of the 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 does not indicate how you pass the resource manager to the validation structure - does anyone know how to do this?

Thanks!

+3
1

SO ( ).

, .

+1

Source: https://habr.com/ru/post/1719992/


All Articles