admin_lsac 2.0.5 → 2.0.6

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/admin_lsac.d.ts CHANGED
@@ -18,6 +18,7 @@ declare module 'admin_lsac' {
18
18
  name: string;
19
19
  label: string;
20
20
  type: 'dropdown';
21
+ validationSchema?: any;
21
22
  options?: Option[] | undefined;
22
23
  getOptions: () => Promise<Option[]>;
23
24
  }
@@ -18,6 +18,7 @@ declare module 'admin_lsac' {
18
18
  name: string;
19
19
  label: string;
20
20
  type: 'dropdown';
21
+ validationSchema?: any;
21
22
  options?: Option[] | undefined;
22
23
  getOptions: () => Promise<Option[]>;
23
24
  }
@@ -9,12 +9,14 @@ function parseValidation(fields) {
9
9
  return {};
10
10
  }
11
11
  return fields.reduce((acc, field) => {
12
- if (field.type !== 'dropdown' && field.type !== 'object' && field.type !== 'array') {
13
- acc[field.name] = field.validationSchema;
12
+ if (field.type !== 'object' && field.type !== 'array') {
13
+ acc[field.name] = field.validationSchema ? field.validationSchema : '';
14
14
  }
15
15
  else if (field.type === 'array') {
16
16
  if (field.element.type === 'dropdown') {
17
- acc[field.name] = Yup.array().of(Yup.string().required());
17
+ acc[field.name] = field.element.validationSchema
18
+ ? Yup.array().of(field.element.validationSchema)
19
+ : '';
18
20
  }
19
21
  else if (field.element.type === 'object') {
20
22
  acc[field.name] = Yup.array().of(Yup.object(parseValidation(field.element.fields)));
@@ -26,9 +28,6 @@ function parseValidation(fields) {
26
28
  else if (field.type === 'object') {
27
29
  acc[field.name] = Yup.object(parseValidation(field.fields));
28
30
  }
29
- if (field.type === 'dropdown') {
30
- acc[field.name] = Yup.string().required();
31
- }
32
31
  return acc;
33
32
  }, {});
34
33
  }
@@ -17,6 +17,7 @@ export interface DropdownField {
17
17
  name: string;
18
18
  label: string;
19
19
  type: 'dropdown';
20
+ validationSchema?: any;
20
21
  options?: Option[] | undefined;
21
22
  getOptions: () => Promise<Option[]>;
22
23
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "admin_lsac",
3
3
  "private": false,
4
- "version": "2.0.5",
4
+ "version": "2.0.6",
5
5
  "description": "Generic Admin Panel created for storing events' data",
6
6
  "scripts": {
7
7
  "dev": "vite",