mirror of
https://github.com/strapi/strapi.git
synced 2025-07-23 00:51:17 +00:00
36 lines
684 B
JavaScript
36 lines
684 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()
|
|
.min(1)
|
|
.required(),
|
|
})
|
|
.noUnknown();
|
|
|
|
const validateUserCreationInput = data => {
|
|
return userCreationSchema.validate(data, { strict: true, abortEarly: false }).catch(handleReject);
|
|
};
|
|
|
|
module.exports = {
|
|
validateUserCreationInput,
|
|
};
|