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.
35 lines
1.1 KiB
35 lines
1.1 KiB
import * as yup from 'yup'; |
|
|
|
import { REP_IPV4 } from '../../lib/consts/REG_EXP_PATTERNS'; |
|
|
|
const schema = yup.object().shape( |
|
{ |
|
enterpriseKey: yup.string().uuid().optional(), |
|
ip: yup.string().matches(REP_IPV4, { |
|
message: 'Expected IP address to be a valid IPv4 address.', |
|
}), |
|
name: yup.string().required(), |
|
redhatConfirmPassword: yup |
|
.string() |
|
.when('redhatPassword', (redhatPassword, field) => |
|
String(redhatPassword).length > 0 |
|
? field.required().oneOf([yup.ref('redhatPassword')]) |
|
: field.optional(), |
|
), |
|
redhatPassword: yup |
|
.string() |
|
.when('redhatUsername', (redhatUsername, field) => |
|
String(redhatUsername).length > 0 ? field.required() : field.optional(), |
|
), |
|
redhatUsername: yup |
|
.string() |
|
.when('redhatPassword', (redhatPassword, field) => |
|
String(redhatPassword).length > 0 ? field.required() : field.optional(), |
|
), |
|
type: yup.string().oneOf(['dr', 'subnode']).required(), |
|
uuid: yup.string().uuid().required(), |
|
}, |
|
[['redhatUsername', 'redhatPassword']], |
|
); |
|
|
|
export default schema;
|
|
|