Validot is a performance-first, compact library for advanced model validation. Using a simple declarative fluent interface, it efficiently handles classes, structs, nested members, collections, nullables, plus any relation or combination of them. It also supports translations, custom logic extensions with tests, and DI containers.
Chinese translation for the default Validot's message set.
Placeholders support where applicable.
Fluent api extension method to ValidatorSettings so it can be nicely used from Validator.Factory.Create.
Feature in action
var validator = Validator.Factory.Create(
specification,
s => s.WithChineseTranslation()
);
validator.Settings.Translations["Chinese"] // this is the full translation dictionary
validator.Validate(model).ToString(translationName: "Chinese") // gets result error output in Chinese
Feature implementation walkthrough
In Validot, even English language is implemented as a translation that maps the property names from MessageKey class to the human-readable phrases.
Take a look at the files in src/Validot/Translations directory and see how the other languages are implemented.
In the project's root directory execute pwsh build.ps1 --target AddTranslation --translationName Chinese
There is also build.sh if you don't have pwsh installed.
Their role is to check whether the translation dictionary contains only the keys from the MessageKey class.
You don't need to include all keys translated, but if you want to skip something, please comment the line out instead of removing it (later it would be easier to check what's missing).
Done! Now you can make a PR! Thank you for your contribution!
Feature description
ValidatorSettings
so it can be nicely used fromValidator.Factory.Create
.Feature in action
Feature implementation walkthrough
MessageKey
class to the human-readable phrases.pwsh build.ps1 --target AddTranslation --translationName Chinese
build.sh
if you don't have pwsh installed.ChineseTranslation.cs
and translate the English phrases.MessageKey
class.