added deleted status for /samples
This commit is contained in:
@ -168,11 +168,10 @@ export default class SampleValidate {
|
||||
joiObject[param] = Joi.any();
|
||||
});
|
||||
const {value, error} = Joi.object(joiObject).validate(data, {stripUnknown: true});
|
||||
console.log(error);
|
||||
return error !== undefined? null : value;
|
||||
}
|
||||
|
||||
static query (data) {
|
||||
static query (data, dev = false) {
|
||||
if (data.filters && data.filters.length) {
|
||||
const filterValidation = Joi.array().items(Joi.string()).validate(data.filters);
|
||||
if (filterValidation.error) return filterValidation;
|
||||
@ -216,8 +215,12 @@ export default class SampleValidate {
|
||||
return {error: {details: [{message: 'Invalid JSON string for filter parameter'}]}, value: null}
|
||||
}
|
||||
}
|
||||
const acceptedStatuses = ['validated', 'new'];
|
||||
if (dev) { // dev and admin can also access deleted samples
|
||||
acceptedStatuses.push('deleted')
|
||||
}
|
||||
return Joi.object({
|
||||
status: Joi.string().valid('validated', 'new', 'all'),
|
||||
status: Joi.array().items(Joi.string().valid(...acceptedStatuses)).default(['validated']),
|
||||
'from-id': IdValidate.get(),
|
||||
'to-page': Joi.number().integer(),
|
||||
'page-size': Joi.number().integer().min(1),
|
||||
|
@ -82,7 +82,6 @@ export default class UserValidate { // validate input for user
|
||||
location: this.user.location,
|
||||
devices: this.user.devices
|
||||
}).validate(data, {stripUnknown: true});
|
||||
console.log(data);
|
||||
return error !== undefined? null : value;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user