mirror of
https://framagit.org/les/gancio.git
synced 2025-02-01 00:52:01 +01:00
19 lines
578 B
JavaScript
19 lines
578 B
JavaScript
const linkify = require('linkifyjs')
|
|
|
|
export default ({ app }, inject) => {
|
|
const $t = app.i18n.t.bind(app.i18n)
|
|
const validators = {
|
|
required (fieldName) {
|
|
return value => !!value || $t('validators.required', { fieldName: $t(fieldName) })
|
|
},
|
|
email: [
|
|
v => !!v || $t('validators.required', { fieldName: $t('common.email') }),
|
|
v => (v && !!linkify.test(v, 'email')) || $t('validators.email')
|
|
],
|
|
password: [
|
|
v => !!v || $t('validators.required', { fieldName: $t('common.password') })
|
|
]
|
|
}
|
|
|
|
inject('validators', validators)
|
|
}
|