18 lines
469 B
TypeScript
18 lines
469 B
TypeScript
import Joi from 'joi';
|
|
|
|
export default class NoteFieldValidate {
|
|
private static note_field = {
|
|
name: Joi.string()
|
|
.max(128),
|
|
|
|
qty: Joi.number()
|
|
};
|
|
|
|
static output (data) { // validate output and strip unwanted properties, returns null if not valid
|
|
const {value, error} = Joi.object({
|
|
name: this.note_field.name,
|
|
qty: this.note_field.qty
|
|
}).validate(data, {stripUnknown: true});
|
|
return error !== undefined? null : value;
|
|
}
|
|
} |