mirror of
https://github.com/strapi/strapi.git
synced 2025-07-24 09:25:25 +00:00
26 lines
500 B
JavaScript
26 lines
500 B
JavaScript
'use strict';
|
|
|
|
const yup = require('yup');
|
|
const { formatYupErrors } = require('strapi-utils');
|
|
|
|
const createModelConfigurationSchema = require('./model-configuration');
|
|
|
|
const TYPES = ['singleType', 'collectionType'];
|
|
|
|
/**
|
|
* Validates type kind
|
|
*/
|
|
const validateKind = kind => {
|
|
return yup
|
|
.string()
|
|
.oneOf(TYPES)
|
|
.nullable()
|
|
.validate(kind)
|
|
.catch(error => Promise.reject(formatYupErrors(error)));
|
|
};
|
|
|
|
module.exports = {
|
|
createModelConfigurationSchema,
|
|
validateKind,
|
|
};
|