import { SafeNSoundError } from '#util/error.js'; import Joi from 'joi'; /** * Generic authentication DTO. */ export class AuthDto { static schema = new Joi.object({ password: Joi.string().required(), username: Joi.string(), email: Joi.string().email() }).or('username', 'email'); username; email; password; static async create(data) { const obj = new AuthDto(); for (const key of Object.keys(data)) { if (key in obj) { obj[key] = data[key]; } } return await AuthDto.schema.validateAsync(obj); } }