feat: refs #8387 regular expression all tags
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
c727586855
commit
3d5bfb81da
|
@ -399,5 +399,5 @@
|
||||||
"All tickets have a route order": "Todos los tickets tienen orden de ruta",
|
"All tickets have a route order": "Todos los tickets tienen orden de ruta",
|
||||||
"Price cannot be blank": "Price cannot be blank",
|
"Price cannot be blank": "Price cannot be blank",
|
||||||
"There are tickets to be invoiced": "La zona tiene tickets por facturar",
|
"There are tickets to be invoiced": "La zona tiene tickets por facturar",
|
||||||
"The value must be a number or a range of numbers": "The value must be a number or a range of numbers"
|
"The value must be a number or a range of numbers": "El valor debe ser un número o un rango de números"
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ module.exports = Self => {
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.observe('before save', async ctx => {
|
Self.observe('before save', async ctx => {
|
||||||
const validValue = new RegExp('^\\d{1,3}(-\\d{1,3})?$');
|
|
||||||
let tagFk;
|
let tagFk;
|
||||||
let value;
|
let value;
|
||||||
|
|
||||||
|
@ -24,10 +23,13 @@ module.exports = Self => {
|
||||||
value = ctx.data.value;
|
value = ctx.data.value;
|
||||||
}
|
}
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const validTag = await models.Tag.findOne({where: {name: 'Longitud(m)'}});
|
const validTag = await models.Tag.findOne({where: {id: tagFk}});
|
||||||
|
|
||||||
if (tagFk === validTag.id) {
|
if (validTag.validationRegex) {
|
||||||
if ((value && !validValue.test(value)))
|
const regexString = validTag.validationRegex.replace(/\\\\/g, '\\');
|
||||||
|
const validExpresion = new RegExp(regexString);
|
||||||
|
|
||||||
|
if (value && !validExpresion.test(value))
|
||||||
throw new UserError('The value must be a number or a range of numbers');
|
throw new UserError('The value must be a number or a range of numbers');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -30,6 +30,9 @@
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"columnName": "isQuantitatif"
|
"columnName": "isQuantitatif"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"validationRegex": {
|
||||||
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"acls": [
|
"acls": [
|
||||||
|
|
Loading…
Reference in New Issue