mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 07:49:41 +02:00
refactor(gitops): migrate git form to react [EE-4849] (#8268)
This commit is contained in:
parent
afe6cd6df0
commit
273a3f9a10
130 changed files with 3194 additions and 1190 deletions
19
app/react/components/form-components/validate-form.ts
Normal file
19
app/react/components/form-components/validate-form.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
import { yupToFormErrors } from 'formik';
|
||||
import { SchemaOf } from 'yup';
|
||||
|
||||
export async function validateForm<T>(
|
||||
schemaBuilder: () => SchemaOf<T>,
|
||||
formValues: T
|
||||
) {
|
||||
const validationSchema = schemaBuilder();
|
||||
|
||||
try {
|
||||
await validationSchema.validate(formValues, {
|
||||
strict: true,
|
||||
abortEarly: false,
|
||||
});
|
||||
return undefined;
|
||||
} catch (error) {
|
||||
return yupToFormErrors<T>(error);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue