Open BondarenkoAlex opened 7 years ago
Yes, I agree that to call the prototype method in instance is wrong. This leads to a mess in the procedure .
But it is important to give a chance to change the language from English to any other language.
My question is what is the best way to do it? Maybe we can do it like this: strategy.setDefaultLang('ru');
?
Right, I think I see what's happened. On
validatorjs
2.0.5
, my method in the docs worked for setting the language worked. This kind of thing:Because of the update to
3.9
in master now, that no longer works. But because this is a change to API ofvalidatorjs
, I don't think the way you've done it to support the old method is the right way. If users check the documentation ofvalidatorjs
to see what methods or attributes to set in the callback, they won't see thelang
attribute listed.Instead it looks like the proper way to do it in
validatorjs
is this way:It doesn't look like you can set the language on a specific validator instance anymore as it's a static method so I might just update the documentation to reflect that although that is going slightly into documenting
validatorjs
which I don't really want to do. The language example for the callback was only ever intended as an example to show how the instance could be manipulated after creation.It actually looks like there are no instance methods / attributes in
validatorjs
now (apart frompasses()
andfails()
) so I'm not even sure if the callback is needed anymore.