blob: 281311d8e2dd92f21a6282015aec91986b88553a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
import { SafeNSoundError } from '#util/error.js';
import Joi from 'joi';
import { AlarmType } from '#db/schemas/index.js';
/**
* Generic authentication DTO.
*/
export class AlarmDto {
static schema = new Joi.object({
createdAt: Joi.date().optional(),
reason: Joi.string().valid(...Object.values(AlarmType))
});
createdAt;
reason;
static async create(data) {
const obj = new AlarmDto();
for (const key of Object.keys(data)) {
if (key in obj) {
obj[key] = data[key];
}
}
return await AlarmDto.schema.validateAsync(obj);
}
}
|