Griffin localization and Fluent Validation

二次信任 提交于 2020-01-17 07:08:11

问题


I am new to Griffin localization, it seems very cool. However, examples are only showing me how to translate MVC validation attributes.

I am using minimum if not none of the mvc validation attributes. My idea is (try) not to validate and report messages twice at data layer and UI layer. I create validators at data layer with with Fluent Validation.

Could you please give me a quick pointer (if it exists) how we can integrate Griffin Localization with Fluent Validation at data layer?


回答1:


Griffin.MvcContrib do not have any support for Fluent Validation.

Just took a quick look at fluent validation and it seems like it pulls its string from IStringSource. So you could basically create an adapter for it which reads the strings from the Griffin.MvcContrib resources.

Something like:

public class FluentValidationTranslator : IStringSource 
{
    public FluentValidationTranslator(ILocalizedStringProvider griffinProvider)
    {
    }

    // implement the translation here
}


来源:https://stackoverflow.com/questions/11474293/griffin-localization-and-fluent-validation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!