@jsonforms/core 3.6.0-alpha.1 → 3.6.0-beta.0

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.
@@ -388,15 +388,15 @@ var resolveSchema = function (schema, schemaPath, rootSchema) {
388
388
  };
389
389
  var resolveSchemaWithSegments = function (schema, pathSegments, rootSchema) {
390
390
  var _a, _b, _c, _d, _e;
391
- if (isEmpty__default["default"](schema)) {
392
- return undefined;
393
- }
394
- if (typeof schema.$ref === 'string') {
391
+ if (typeof (schema === null || schema === void 0 ? void 0 : schema.$ref) === 'string') {
395
392
  schema = resolveSchema(rootSchema, schema.$ref, rootSchema);
396
393
  }
397
394
  if (!pathSegments || pathSegments.length === 0) {
398
395
  return schema;
399
396
  }
397
+ if (isEmpty__default["default"](schema)) {
398
+ return undefined;
399
+ }
400
400
  var segment = pathSegments[0], remainingSegments = pathSegments.slice(1);
401
401
  if (invalidSegment(segment)) {
402
402
  return resolveSchemaWithSegments(schema, remainingSegments, rootSchema);
@@ -665,15 +665,19 @@ var isLeafCondition = function (condition) {
665
665
  return condition.type === 'LEAF';
666
666
  };
667
667
  var isSchemaCondition = function (condition) { return has__default["default"](condition, 'schema'); };
668
+ var isValidateFunctionCondition = function (condition) {
669
+ return has__default["default"](condition, 'validate') &&
670
+ typeof condition.validate === 'function';
671
+ };
668
672
  var getConditionScope = function (condition, path) {
669
673
  return composeWithUi(condition, path);
670
674
  };
671
- var evaluateCondition = function (data, condition, path, ajv) {
675
+ var evaluateCondition = function (data, uischema, condition, path, ajv) {
672
676
  if (isAndCondition(condition)) {
673
- return condition.conditions.reduce(function (acc, cur) { return acc && evaluateCondition(data, cur, path, ajv); }, true);
677
+ return condition.conditions.reduce(function (acc, cur) { return acc && evaluateCondition(data, uischema, cur, path, ajv); }, true);
674
678
  }
675
679
  else if (isOrCondition(condition)) {
676
- return condition.conditions.reduce(function (acc, cur) { return acc || evaluateCondition(data, cur, path, ajv); }, false);
680
+ return condition.conditions.reduce(function (acc, cur) { return acc || evaluateCondition(data, uischema, cur, path, ajv); }, false);
677
681
  }
678
682
  else if (isLeafCondition(condition)) {
679
683
  var value = resolveData(data, getConditionScope(condition, path));
@@ -686,13 +690,23 @@ var evaluateCondition = function (data, condition, path, ajv) {
686
690
  }
687
691
  return ajv.validate(condition.schema, value);
688
692
  }
693
+ else if (isValidateFunctionCondition(condition)) {
694
+ var value = resolveData(data, getConditionScope(condition, path));
695
+ var context = {
696
+ data: value,
697
+ fullData: data,
698
+ path: path,
699
+ uischemaElement: uischema,
700
+ };
701
+ return condition.validate(context);
702
+ }
689
703
  else {
690
704
  return true;
691
705
  }
692
706
  };
693
707
  var isRuleFulfilled = function (uischema, data, path, ajv) {
694
708
  var condition = uischema.rule.condition;
695
- return evaluateCondition(data, condition, path, ajv);
709
+ return evaluateCondition(data, uischema, condition, path, ajv);
696
710
  };
697
711
  var evalVisibility = function (uischema, data, path, ajv) {
698
712
  if (path === void 0) { path = undefined; }