mirror of https://github.com/portainer/portainer
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import { SchemaOf, object, string, boolean, number } from 'yup';
|
|
|
|
import { isValidUrl } from '@@/form-components/validate-url';
|
|
|
|
import { FormValues } from './types';
|
|
|
|
export function validation(): SchemaOf<FormValues> {
|
|
return object().shape({
|
|
helmRepositoryUrl: string()
|
|
.default('')
|
|
.test('valid-url', 'Invalid URL', (value) => !value || isValidUrl(value)),
|
|
kubeconfigExpiry: string().required(),
|
|
globalDeploymentOptions: object().shape({
|
|
hideAddWithForm: boolean().required(),
|
|
perEnvOverride: boolean().required(),
|
|
hideWebEditor: boolean().required(),
|
|
hideFileUpload: boolean().required(),
|
|
requireNoteOnApplications: boolean().required(),
|
|
hideStacksFunctionality: boolean().required(),
|
|
minApplicationNoteLength: number()
|
|
.typeError('Must be a number')
|
|
.default(0)
|
|
.when('requireNoteOnApplications', {
|
|
is: true,
|
|
then: (schema) =>
|
|
schema
|
|
.required()
|
|
.min(1, 'Value should be between 1 to 9999')
|
|
.max(9999, 'Value should be between 1 to 9999'),
|
|
}),
|
|
}),
|
|
});
|
|
}
|