DanFMoore / react-validatorjs-strategy

Strategy for using validatorjs with react-validation-mixin
The Unlicense
10 stars 5 forks source link

Language #7

Open BondarenkoAlex opened 7 years ago

BondarenkoAlex commented 7 years ago

Hello. How can I set the language 'ru' ?

DanFMoore commented 7 years ago

You can do it like this (see third parameter):

this.validatorTypes = strategy.createSchema(
    // First parameter is a list of rules for each element name
    {
        name: 'required',
        email: 'required|email',
        age: 'min:18'
    },
    // Second parameter is optional and is a list of custom error messages for elements
    {
        "required.email": "Without an :attribute we can't reach you!"
    }
    // Third parameter is also optional; a callback that takes the validator instance created
    // and can be used to call methods on it. This is run at the point of validation.
    function (validator) {
        validator.lang = 'ru';
    }
);