@simpozio/contact-form
Version:
Package for Contact Form component
38 lines • 1.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/* eslint-disable lodash/prefer-lodash-method */
var yup_1 = require("yup");
var schema = yup_1.object().shape({
name: yup_1.string()
.trim()
.max(30)
.required(),
phone: yup_1.string().when('email', {
is: '',
then: yup_1.string()
.trim()
.min(8)
.max(16)
.matches(/^\+[0-9]+$/)
.required(),
otherwise: yup_1.lazy(function (value) {
if (value === '')
return yup_1.string();
return yup_1.string()
.trim()
.min(8)
.max(16)
.matches(/^\+[0-9]+$/);
})
}),
email: yup_1.string()
.trim()
.email()
.when('phone', {
is: '',
then: yup_1.string().required(),
otherwise: yup_1.string()
})
}, [['email', 'phone']]);
exports.default = schema;
//# sourceMappingURL=validSchema.js.map