Archived
2

Implemented filters for no condition or measurement

This commit is contained in:
VLE2FE
2020-09-02 16:19:40 +02:00
parent bdff2c96d3
commit 364ad1964e
4 changed files with 61 additions and 1 deletions

View File

@ -98,6 +98,7 @@ export default class SampleValidate {
'user_id',
'material._id',
'material.numbers',
'measurements',
`measurements.${globals.spectrum.spectrum}.${globals.spectrum.dpt}`,
];
@ -226,6 +227,12 @@ export default class SampleValidate {
});
field = 'value';
}
else if (field === 'measurements') {
validator = Joi.object({
value: Joi.object({}).allow(null).disallow({})
});
field = 'value';
}
else if (field === 'notes.comment') {
field = 'comment';
validator = this.sample.notes
@ -234,6 +241,7 @@ export default class SampleValidate {
validator = Joi.object(this.sample);
}
const {value, error} = validator.validate({[field]: e});
console.log(error);
if (error) throw error; // reject invalid values
return value[field];
});