summary refs log tree commit diff
path: root/src/dto/auth/DeviceDto.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/dto/auth/DeviceDto.js')
-rw-r--r--src/dto/auth/DeviceDto.js36
1 files changed, 0 insertions, 36 deletions
diff --git a/src/dto/auth/DeviceDto.js b/src/dto/auth/DeviceDto.js
deleted file mode 100644

index 40f1959..0000000 --- a/src/dto/auth/DeviceDto.js +++ /dev/null
@@ -1,36 +0,0 @@ -import { SafeNSoundError } from '#util/error.js'; -import Joi from 'joi'; - -export class RegisterDto { - static schema = new Joi.object({ - username: Joi.string().required(), - email: Joi.string().email().required(), - password: Joi.string().required(), - type: Joi.string().valid('user', 'monitor', 'admin').required() - }); - - username; - email; - password; - type = 'user'; - - static async create(data) { - const obj = new RegisterDto(); - for (const key of Object.keys(data)) { - if (key in obj) { - obj[key] = data[key]; - } - } - - try { - return await RegisterDto.schema.validateAsync(obj); - } catch (e) { - console.log(e); - throw new SafeNSoundError({ - errCode: 'JOI_VALIDATION_ERROR', - message: e.message, - validation_details: e.details - }); - } - } -}