diff --git a/src/composables/useValidator.js b/src/composables/useValidator.js index 3f9f00367..5ad96ea1b 100644 --- a/src/composables/useValidator.js +++ b/src/composables/useValidator.js @@ -30,6 +30,15 @@ export function useValidator() { const { t } = useI18n(); const validations = function (validation) { return { + format: (value) => { + const { allowNull, with: format, allowBlank } = validation; + const message = t(validation.message) || validation.message; + if (!allowBlank && value === '') return message; + if (!allowNull && value === null) return message; + + const isValid = new RegExp(format).test(value); + if (!isValid) return message; + }, presence: (value) => { let message = `Value can't be empty`; if (validation.message)