You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ngcp-csc-ui/src/boot/vuelidate.js

26 lines
641 B

import { errorMessages } from 'src/validators'
export const getErrorMessage = (v$) => {
if (v$ && v$.length) {
if (v$[0].$validator && errorMessages[v$[0].$validator]) {
return errorMessages[v$[0].$validator](v$[0].$params, v$[0])
}
}
return ''
}
// Composable for Composition API
export function useValidationErrors () {
return {
getErrorMessage
}
}
export default ({ app }) => {
// Add to global properties for Options API
app.config.globalProperties.$errMsg = getErrorMessage
// Provide for Composition API
app.provide('validationErrors', { getErrorMessage })
}