Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix-front into 4666-invoiceInCorrection
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-02-07 15:53:14 +01:00
commit e2facf3330
1 changed files with 9 additions and 0 deletions

View File

@ -30,6 +30,15 @@ export function useValidator() {
const { t } = useI18n(); const { t } = useI18n();
const validations = function (validation) { const validations = function (validation) {
return { 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) => { presence: (value) => {
let message = `Value can't be empty`; let message = `Value can't be empty`;
if (validation.message) if (validation.message)