@onehat/ui 0.2.5 → 0.2.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/package.json +1 -1
- package/src/Components/Form/Form.js +17 -17
package/package.json
CHANGED
|
@@ -493,26 +493,26 @@ function disableRequiredYupFields(validator) {
|
|
|
493
493
|
return null;
|
|
494
494
|
}
|
|
495
495
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
496
|
+
const nextSchema = validator.clone();
|
|
497
|
+
return nextSchema.withMutation((next) => {
|
|
498
|
+
if (typeof next.fields === 'object' && next.fields != null) {
|
|
499
|
+
for (const key in next.fields) {
|
|
500
|
+
const nestedField = next.fields[key];
|
|
501
501
|
|
|
502
|
-
|
|
502
|
+
let nestedFieldNext = nestedField.notRequired();
|
|
503
503
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
504
|
+
if (Array.isArray(nestedField.conditions) && nestedField.conditions.length > 0) {
|
|
505
|
+
// Next is done to disable required() inside a condition
|
|
506
|
+
// https://github.com/jquense/yup/issues/1002
|
|
507
|
+
nestedFieldNext = nestedFieldNext.when('whatever', (unused, schema) => {
|
|
508
|
+
return schema.notRequired();
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
511
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
512
|
+
next.fields[key] = nestedFieldNext;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
516
|
}
|
|
517
517
|
function getNullFieldValues(initialValues, Repository) {
|
|
518
518
|
const ret = {};
|