Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
yup.addMethod(yup.mixed, 'defined', function() {
return this.test(
'defined',
errorsTrads.required,
value => value !== undefined
);
});
yup.addMethod(yup.mixed, 'defined', function() {
return this.test(
'defined',
errorsTrads.required,
value => value !== undefined
);
});
yup.addMethod(yup.mixed, 'defined', function() {
return this.test(
'defined',
errorsTrads.required,
value => value !== undefined
);
});
name: 'news',
type: 'checkbox',
value: false,
},
],
],
schema: yup.object({
email: yup
.string()
.email(translatedErrors.email)
.required(translatedErrors.required),
username: yup.string().required(translatedErrors.required),
password: yup
.string()
.min(6, translatedErrors.minLength)
.required(translatedErrors.required),
passwordConfirmation: yup
.string()
.min(6, translatedErrors.minLength)
.oneOf(
[yup.ref('password'), null],
'components.Input.error.password.noMatch'
)
.required(translatedErrors.required),
}),
},
'reset-password': {
endPoint: 'reset-password',
inputs: [
[
{
name: 'password',
Object.keys(validations).forEach(validation => {
const validationValue = validations[validation];
if (
!!validationValue ||
((!isBoolean(validationValue) &&
Number.isInteger(Math.floor(validationValue))) ||
validationValue === 0)
) {
switch (validation) {
case 'required':
schema = schema.required(errorsTrads.required);
break;
case 'max':
schema = schema.max(validationValue, errorsTrads.max);
break;
case 'maxLength':
schema = schema.max(validationValue, errorsTrads.maxLength);
break;
case 'min':
schema = schema.min(validationValue, errorsTrads.min);
break;
case 'minLength':
schema = schema.min(validationValue, errorsTrads.minLength);
break;
case 'regex':
schema = schema.matches(validationValue, errorsTrads.regex);
break;
[
{
label: {
id: 'Auth.form.forgot-password.email.label',
},
name: 'email',
type: 'email',
placeholder: 'Auth.form.forgot-password.email.placeholder',
},
],
],
schema: yup.object({
email: yup
.string()
.email(translatedErrors.email)
.required(translatedErrors.required),
}),
},
login: {
endPoint: 'local',
inputs: [
[
{
label: {
id: 'Auth.form.login.username.label',
},
name: 'identifier',
type: 'text',
placeholder: 'Auth.form.login.username.placeholder',
},
],
[
return yup.object().shape({
name: yup
.string()
.unique(
errorsTrads.unique,
takenNames,
createComponentUid,
componentCategory
)
.isAllowed(getTrad('error.contentTypeName.reserved-name'))
.required(errorsTrads.required),
category: yup
.string()
.matches(CATEGORY_NAME_REGEX, errorsTrads.regex)
.required(errorsTrads.required),
icon: yup.string().required(errorsTrads.required),
collectionName: yup.string().nullable(),
});
},
form: {
if (attribute.type === 'dynamiczone') {
let dynamicZoneSchema = yup.array().of(
yup.lazy(({ __component }) => {
return createYupSchema(components[__component], { components });
})
);
const { max, min } = attribute;
if (attribute.required) {
dynamicZoneSchema = dynamicZoneSchema.required();
if (min) {
dynamicZoneSchema = dynamicZoneSchema
.min(min, errorsTrads.min)
.required(errorsTrads.required);
}
} else {
if (min) {
dynamicZoneSchema = dynamicZoneSchema.notEmptyMin(min);
}
}
if (max) {
dynamicZoneSchema = dynamicZoneSchema.max(max, errorsTrads.max);
}
acc[current] = dynamicZoneSchema;
}
return acc;
}, {})