Compare commits
2 Commits
ce3da6841c
...
e5e97a047f
Author | SHA1 | Date |
---|---|---|
Javier Segarra | e5e97a047f | |
Javier Segarra | 0a76b6843f |
|
@ -1,4 +1,6 @@
|
|||
Are you sure exit without saving?: ¿Seguro que quieres salir sin guardar?
|
||||
Unsaved changes will be lost: Los cambios que no hayas guardado se perderán
|
||||
No changes to save: No hay cambios que guardar
|
||||
Some fields are invalid: Algunos campos no son válidos
|
||||
Field are invalid: El campo {{tag}} no es válido
|
||||
Some fields are invalid: Algunos campos no son válidos
|
||||
|
||||
|
|
|
@ -317,8 +317,10 @@ export default class Watcher extends Component {
|
|||
* Checks if the form is valid.
|
||||
*/
|
||||
isInvalid() {
|
||||
if (this.form && this.form.$invalid)
|
||||
throw new UserError('Some fields are invalid');
|
||||
if (this.form && this.form.$invalid) {
|
||||
const tag = Object.values(this.form.$error)[0][0].$$attr.label;
|
||||
throw new UserError(this.$t('Field are invalid', {tag: this.$t(tag)}));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -334,8 +334,8 @@
|
|||
"countryFk cannot be empty": "countryFk cannot be empty",
|
||||
"Model is not valid": "El campo \" {{key}}\" no es válido",
|
||||
"Property is not defined in this model": "La propiedad que ha modificado no existe",
|
||||
"postcode": "Código postal",
|
||||
"postCode": "Código postal",
|
||||
"postcode": "Código postal",
|
||||
"fi": "NIF/CIF",
|
||||
"nif": "NIF/CIF",
|
||||
"Account": "Cuenta",
|
||||
|
@ -348,5 +348,8 @@
|
|||
"healthRegister":"Registro sanitario",
|
||||
"sageTaxTypeFk":"Tipo de impuesto Sage",
|
||||
"sageTransactionTypeFk":"Tipo de transacción Sage",
|
||||
"sageWithholdingFk" : "Sage con tenencia"
|
||||
"sageWithholdingFk" : "Sage con tenencia",
|
||||
"Cannot past travels with entries": "No se pueden pasar envíos con entradas",
|
||||
"It was not able to remove the next expeditions:": "No se pudo eliminar las siguientes expediciones: {{expeditions}}",
|
||||
"Field are invalid": "El campo {{tag}} no es válido"
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
const UserError = require('../../util/user-error');
|
||||
const logToConsole = require('strong-error-handler/lib/logger');
|
||||
|
||||
const validations = [{
|
||||
validation: message => String(message).startsWith('Value is not'),
|
||||
message: ({__: $t, body}) => $t('Field are invalid', {tag: $t(Object.keys(body)[0])})
|
||||
}];
|
||||
module.exports = function() {
|
||||
return function(err, req, res, next) {
|
||||
// Thrown user errors
|
||||
|
@ -10,6 +13,16 @@ module.exports = function() {
|
|||
}
|
||||
|
||||
// Validation errors
|
||||
if (err.statusCode == 400) {
|
||||
try {
|
||||
validations.forEach(validation => {
|
||||
err.message = validation.validation(err.message) && validation.message(req);
|
||||
});
|
||||
|
||||
return next(err);
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
if (err.statusCode == 422) {
|
||||
try {
|
||||
let code;
|
||||
|
|
Loading…
Reference in New Issue