2020-01-06 16:01:42 +01:00
|
|
|
import * as yup from 'yup';
|
2020-01-10 15:30:34 +01:00
|
|
|
import { translatedErrors } from 'strapi-helper-plugin';
|
2020-01-15 12:17:44 +01:00
|
|
|
import { NAME_REGEX, URL_REGEX } from './fieldsRegex';
|
|
|
|
|
|
|
|
const schema = yup.object().shape({
|
|
|
|
name: yup
|
|
|
|
.string(translatedErrors.string)
|
|
|
|
.nullable()
|
|
|
|
.required(translatedErrors.required)
|
|
|
|
.matches(NAME_REGEX, translatedErrors.regex),
|
|
|
|
url: yup
|
|
|
|
.string(translatedErrors.string)
|
|
|
|
.nullable()
|
|
|
|
.required(translatedErrors.required)
|
|
|
|
.matches(URL_REGEX, translatedErrors.regex),
|
|
|
|
headers: yup
|
|
|
|
.array()
|
|
|
|
.of(
|
|
|
|
yup.object().shape({
|
|
|
|
key: yup.string().required(),
|
|
|
|
value: yup.string().required(),
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.nullable(),
|
|
|
|
events: yup
|
|
|
|
.array()
|
|
|
|
.nullable()
|
|
|
|
.required(translatedErrors.required),
|
|
|
|
});
|
|
|
|
|
|
|
|
export default schema;
|