1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-22 23:09:41 +02:00

refactor(app): migrate env var form section [EE-6232] (#10499)

* refactor(app): migrate env var form section [EE-6232]

* allow undoing delete in inputlist
This commit is contained in:
Ali 2024-01-03 08:17:54 +13:00 committed by GitHub
parent 6228314e3c
commit 488393007f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 274 additions and 209 deletions

View file

@ -0,0 +1,26 @@
import { SchemaOf, array, bool, object, string } from 'yup';
import { EnvVar } from '@@/form-components/EnvironmentVariablesFieldset/types';
import { buildUniquenessTest } from '@@/form-components/validate-unique';
export function kubeEnvVarValidationSchema(): SchemaOf<EnvVar[]> {
return array(
object({
name: string()
.required('Name is required')
.matches(
/^[a-zA-Z][a-zA-Z0-9_.-]*$/,
`This field must consist of alphabetic characters, digits, '_', '-', or '.', and must not start with a digit (e.g. 'my.env-name', or 'MY_ENV.NAME', or 'MyEnvName1'.`
),
value: string().default(''),
needsDeletion: bool().default(false),
})
).test(
'unique',
'This environment variable is already defined.',
buildUniquenessTest(
() => 'This environment variable is already defined.',
'name'
)
);
}