Archived
2
This repository has been archived on 2023-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
definma-api/src/routes/validate/note_field.ts

18 lines
398 B
TypeScript
Raw Normal View History

2020-05-07 21:55:29 +02:00
import Joi from '@hapi/joi';
2020-05-06 14:39:04 +02:00
export default class NoteFieldValidate {
private static note_field = {
2020-05-07 21:55:29 +02:00
name: Joi.string()
2020-05-06 14:39:04 +02:00
.max(128),
2020-05-07 21:55:29 +02:00
qty: Joi.number()
2020-05-06 14:39:04 +02:00
};
static output (data) {
2020-05-07 21:55:29 +02:00
const {value, error} = Joi.object({
2020-05-06 14:39:04 +02:00
name: this.note_field.name,
qty: this.note_field.qty
}).validate(data, {stripUnknown: true});
return error !== undefined? null : value;
}
}