@fincity/kirun-js 2.14.0 → 2.15.1

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.
@@ -198,12 +198,16 @@ export class SchemaValidator {
198
198
  }
199
199
  }
200
200
 
201
+ if (errors.length == 1) {
202
+ throw new SchemaValidationException(
203
+ SchemaValidator.path(parents),
204
+ errors[0].message);
205
+ }
206
+
201
207
  throw new SchemaValidationException(
202
208
  SchemaValidator.path(parents),
203
209
  'Value ' + JSON.stringify(element) + ' is not of valid type(s)',
204
210
  errors,
205
211
  );
206
212
  }
207
-
208
- private constructor() {}
209
213
  }
@@ -76,11 +76,13 @@ export class StringValidator {
76
76
  if (schema.getMinLength() && length < schema.getMinLength()!) {
77
77
  throw new SchemaValidationException(
78
78
  SchemaValidator.path(parents),
79
+ schema.getDetails()?.getValidationMessage('minLength') ??
79
80
  'Expected a minimum of ' + schema.getMinLength() + ' characters',
80
81
  );
81
82
  } else if (schema.getMaxLength() && length > schema.getMaxLength()!) {
82
83
  throw new SchemaValidationException(
83
84
  SchemaValidator.path(parents),
85
+ schema.getDetails()?.getValidationMessage('maxLength') ??
84
86
  'Expected a maximum of ' + schema.getMaxLength() + ' characters',
85
87
  );
86
88
  }
@@ -99,6 +101,7 @@ export class StringValidator {
99
101
  if (!matched) {
100
102
  throw new SchemaValidationException(
101
103
  SchemaValidator.path(parents),
104
+ schema.getDetails()?.getValidationMessage('pattern') ??
102
105
  element.toString() + ' is not matched with the ' + message,
103
106
  );
104
107
  }
@@ -777,4 +777,4 @@ export class KIRuntime extends AbstractFunction {
777
777
 
778
778
  return new Tuple2(retValue, retMap);
779
779
  }
780
- }
780
+ }