Implemented filters for no condition or measurement
This commit is contained in:
@ -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];
|
||||
});
|
||||
|
Reference in New Issue
Block a user