Vue-form-generator: How to translate validator messages?

Created on 28 Feb 2017  路  5Comments  路  Source: vue-generators/vue-form-generator

How can I translate built-in validator messages? Is it possible? I need it in Polish...

question

Most helpful comment

Yes, it is possible. You need to overwrite the resources props in validators.

        created() {
            var res = VueFormGenerator.validators.resources;
            res.textTooSmall = "T煤l r枚vid a sz枚veg!"
        }

Example fiddle

if you delete the password you will see the custom validator message

All 5 comments

Yes, it is possible. You need to overwrite the resources props in validators.

        created() {
            var res = VueFormGenerator.validators.resources;
            res.textTooSmall = "T煤l r枚vid a sz枚veg!"
        }

Example fiddle

if you delete the password you will see the custom validator message

I did something like this yesterday and it was working, when I did it at the component level, but I don't know how to setup it once for the whole app (I have few forms in my app). This code should be placed at the created() method of the main App.vue component?

You can place this code everywhere after vfg imported. E.g. App.vue created or mounted. Example

Translations are working fine, thanks!

Now I have an issue with number validators :( Validators (nubmer, integer, double) uses lodash isNumber function, which evaluates to false if argument is type of string. Maybe I'm wrong, but value, which is returned from input is type of string and should be converted to number before validation? I tested it with field type='input' and inputType='number' / 'integer' / 'double' and always get 'Invalid number!'
https://lodash.com/docs/4.17.4#isNumber

@gkurdej please open a new issue about it and if you can please create a jsfiddle.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jaywilburn picture jaywilburn  路  3Comments

LouWii picture LouWii  路  4Comments

pimhooghiemstra picture pimhooghiemstra  路  5Comments

blackfyre picture blackfyre  路  4Comments

icetee picture icetee  路  4Comments