Open alisherafat01 opened 7 years ago
Any progress on this issue?
Hi, I am not a library owner, so my opinion may be different and not committed to be the true one.
As I understand you need something like global .setAttributeNames. Here is what I think.
class Validator
is responsible for creating a validator
instance. And as it is a constructor it defines the properties and methods for instance and holds some generic data. Class Validator
does not interact with your form and knows nothing about your form fields(and about your form at all), but instance (validator
) does.
Following your request, you are asking to break an encapsulation - in my opinion, this does not look good from the architectural point of view. The current implementation allows keeping some separation or responsibilities and roles.
What do you think?
Btw, @alisherafat can you help with one rule translation into Persian('fa') language? it is a "hex" rule https://github.com/skaterdav85/validatorjs/blob/master/src/lang/fa.js Can you reply me with translation here?
Hi @vict-shevchenko
Translation of hex rule for fa_IR is:
hex: 'فیلد :attribute باید در فرمت مبنای ۱۶ باشد'
As answered herer Laravel validator has option to modify attributeNames for a specific language globally and there is nothing wrong with that and is good thing to implement here.
actually attributes:{}
property should be modifiable here
This has been tagged as a feature request and will consider this addition for a future release.
Cool! Glad to know this. Thanks a lot for translation.
I know how to set custom attribute names for an instance of validator but I want to know is it possible to set them globally? (i need something like below):
var validator = require('validatorjs'); validator.useLang('fa'); validator.setAttributes('fa',{ age: 'سن', full_name: 'نام کامل', ... });