fixed multiple template measurements
This commit is contained in:
@ -6,6 +6,7 @@ import MaterialValidate from './material';
|
||||
import MeasurementValidate from './measurement';
|
||||
import globals from '../../globals';
|
||||
|
||||
|
||||
export default class SampleValidate {
|
||||
private static sample = {
|
||||
number: Joi.string()
|
||||
@ -56,6 +57,19 @@ export default class SampleValidate {
|
||||
.valid(...Object.values(globals.status))
|
||||
};
|
||||
|
||||
static readonly sampleKeys = [ // keys which can be found in the sample directly
|
||||
'_id',
|
||||
'color',
|
||||
'number',
|
||||
'type',
|
||||
'batch',
|
||||
'added',
|
||||
'condition',
|
||||
'material_id',
|
||||
'note_id',
|
||||
'user_id'
|
||||
];
|
||||
|
||||
private static sortKeys = [
|
||||
'_id',
|
||||
'color',
|
||||
@ -68,6 +82,7 @@ export default class SampleValidate {
|
||||
'material.supplier',
|
||||
'material.group',
|
||||
'material.properties.*',
|
||||
'condition.*',
|
||||
`measurements.(?!${globals.spectrum.spectrum}.${globals.spectrum.dpt})*`
|
||||
];
|
||||
|
||||
@ -189,7 +204,7 @@ export default class SampleValidate {
|
||||
});
|
||||
field = field.replace('material.', '').split('.')[0];
|
||||
}
|
||||
else if (/measurements\./.test(field)) {
|
||||
else if (/measurements\./.test(field) || /condition\./.test(field)) {
|
||||
validator = Joi.object({
|
||||
value: Joi.alternatives()
|
||||
.try(
|
||||
|
@ -1,7 +1,6 @@
|
||||
import Joi from 'joi';
|
||||
import IdValidate from './id';
|
||||
|
||||
// TODO: do not allow a . in the name !!!
|
||||
export default class TemplateValidate {
|
||||
private static template = {
|
||||
name: Joi.string()
|
||||
|
Reference in New Issue
Block a user