@campxdev/shared 1.7.2 → 1.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -17,9 +17,9 @@ interface FormProps extends Omit<RenderFormProps, 'control'> {
|
|
|
17
17
|
previousData?: any
|
|
18
18
|
onCancel?: () => void
|
|
19
19
|
postFunction: (body: any) => Promise<AxiosResponse>
|
|
20
|
-
onPostSuccess
|
|
21
|
-
onPostError
|
|
22
|
-
onFormError
|
|
20
|
+
onPostSuccess?: (response: any) => void
|
|
21
|
+
onPostError?: (error: any) => void
|
|
22
|
+
onFormError?: (error: any) => void
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export default function Form({
|
|
@@ -9,11 +9,12 @@ import {
|
|
|
9
9
|
FormTextField,
|
|
10
10
|
} from '../HookForm'
|
|
11
11
|
|
|
12
|
-
export const generateYupSchema = (
|
|
13
|
-
|
|
14
|
-
fieldArrayGroups?: any[]
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
export const generateYupSchema = (options: {
|
|
13
|
+
fieldGroups: any[][]
|
|
14
|
+
fieldArrayGroups?: any[]
|
|
15
|
+
extraValidations?: any
|
|
16
|
+
}) => {
|
|
17
|
+
const flatArray = options.fieldGroups.flat()
|
|
17
18
|
|
|
18
19
|
const validations = flatArray
|
|
19
20
|
?.filter(
|
|
@@ -28,7 +29,7 @@ export const generateYupSchema = (
|
|
|
28
29
|
}
|
|
29
30
|
}, {})
|
|
30
31
|
|
|
31
|
-
return yup.object().shape(validations)
|
|
32
|
+
return yup.object().shape({ ...validations, ...options.extraValidations })
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
type FormTypes =
|