2025-05-12 16:10:41 +02:00
|
|
|
const Ajv = require("ajv");
|
2025-05-25 23:21:15 +02:00
|
|
|
const addFormats = require("ajv-formats")
|
|
|
|
const ajv = new Ajv({formats: {email: true}});
|
2025-05-12 16:10:41 +02:00
|
|
|
|
|
|
|
// --- Schemas ---
|
|
|
|
//TODO
|
|
|
|
|
|
|
|
const newUserSchema = {
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
2025-05-25 23:21:15 +02:00
|
|
|
username: { type: 'string' }, //TODO
|
|
|
|
display_name: { type: 'string'},
|
|
|
|
email: { type: 'string', format: 'email' }, //TODO
|
|
|
|
password: { type: 'string', minLength: 6, maxLength: 255 },
|
|
|
|
profile_picture: {type: 'string'} //TODO
|
2025-05-12 16:10:41 +02:00
|
|
|
},
|
|
|
|
required: ['name', 'email', 'password'],
|
|
|
|
additionalProperties: false
|
|
|
|
};
|
|
|
|
|
2025-05-25 23:21:15 +02:00
|
|
|
addFormats(ajv, ['email']);
|
2025-05-12 16:10:41 +02:00
|
|
|
const validateNewUserData = ajv.compile(newUserSchema);
|
|
|
|
|
|
|
|
|
|
|
|
// --- Exports ---
|
|
|
|
|
|
|
|
module.exports = { validateNewUserData };
|