mirror of
https://github.com/strapi/strapi.git
synced 2025-07-23 17:10:08 +00:00
33 lines
639 B
JavaScript
33 lines
639 B
JavaScript
'use strict';
|
|
|
|
const { yup, formatYupErrors } = require('strapi-utils');
|
|
|
|
const handleReject = error => Promise.reject(formatYupErrors(error));
|
|
|
|
const userCreationSchema = yup.object().shape({
|
|
email: yup
|
|
.string()
|
|
.email()
|
|
.required(),
|
|
firstname: yup
|
|
.string()
|
|
.min(1)
|
|
.required(),
|
|
lastname: yup
|
|
.string()
|
|
.min(1)
|
|
.required(),
|
|
roles: yup
|
|
.array()
|
|
.of(yup.number())
|
|
.required(),
|
|
});
|
|
|
|
const validateUserCreationInput = data => {
|
|
return userCreationSchema.validate(data, { strict: true, abortEarly: false }).catch(handleReject);
|
|
};
|
|
|
|
module.exports = {
|
|
validateUserCreationInput,
|
|
};
|