mwc-components
Version:
## Project setup ``` yarn install ```
73 lines (68 loc) • 1.45 kB
JavaScript
import { required, minLength, email } from 'vuelidate/lib/validators'
const fields = (labeler) => {
return [
{
title: labeler.getLabel(`emailText`),
id: 'emailInput',
described: 'email-error',
error: labeler.getLabel(`emailErrorText`),
type: 'email'
},
{
title: labeler.getLabel(`userNameText`),
id: 'userNameInput',
described: 'username-error',
error: labeler.getLabel(`usernameErrorText`),
type: 'text'
},
{
title: labeler.getLabel(`passwordText`),
id: 'passwordInput',
described: 'pw-error',
error: labeler.getLabel(`passwordErrorText`),
type: 'password'
}
]
}
const validations = {
emailInput: {
required,
email
},
passwordInput: {
required,
minLength: minLength(6)
},
userNameInput: {
required
}
}
let emailCompare = (v) => {
return (
!v.emailInput.$error &&
!v.passwordInput.$error &&
!v.emailInput.$invalid &&
!v.passwordInput.$invalid &&
v.emailInput.$dirty &&
v.passwordInput.$dirty
)
}
let userNameCompare = (v) => {
return (
!v.passwordInput.$error &&
!v.userNameInput.$error &&
!v.userNameInput.$invalid &&
!v.passwordInput.$invalid &&
v.passwordInput.$dirty &&
v.userNameInput.$dirty
)
}
const comparingMethod = {
email: emailCompare,
userName: userNameCompare
}
export default {
fields,
validations,
comparingMethod
}