You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
873 B
28 lines
873 B
10 months ago
|
import * as yup from 'yup';
|
||
|
|
||
|
import buildYupDynamicObject from '../../lib/buildYupDynamicObject';
|
||
|
|
||
|
const mailServerSchema = yup.object({
|
||
|
address: yup.string().required(),
|
||
|
authentication: yup.string().oneOf(['none', 'plain-text', 'encrypted']),
|
||
|
confirmPassword: yup
|
||
|
.string()
|
||
|
.when('password', (password, field) =>
|
||
|
String(password).length > 0
|
||
|
? field.required().oneOf([yup.ref('password')])
|
||
|
: field.optional(),
|
||
|
),
|
||
|
heloDomain: yup.string().required(),
|
||
|
password: yup.string().optional(),
|
||
|
port: yup.number().required(),
|
||
|
security: yup.string().oneOf(['none', 'starttls', 'tls-ssl']),
|
||
|
username: yup.string().optional(),
|
||
|
uuid: yup.string().uuid().required(),
|
||
|
});
|
||
|
|
||
|
const mailServerListSchema = yup.lazy((mailServers) =>
|
||
|
yup.object(buildYupDynamicObject(mailServers, mailServerSchema)),
|
||
|
);
|
||
|
|
||
|
export default mailServerListSchema;
|