|
@@ -70,10 +70,10 @@ function getDataTypeFromValue(value) {
|
|
|
__name(getDataTypeFromValue, "getDataTypeFromValue");
|
|
__name(getDataTypeFromValue, "getDataTypeFromValue");
|
|
|
|
|
|
|
|
// src/data-parser.js
|
|
// src/data-parser.js
|
|
|
-var import_js_service16 = require("@e22m4u/js-service");
|
|
|
|
|
|
|
+var import_js_service5 = require("@e22m4u/js-service");
|
|
|
|
|
|
|
|
// src/data-validator.js
|
|
// src/data-validator.js
|
|
|
-var import_js_service9 = require("@e22m4u/js-service");
|
|
|
|
|
|
|
+var import_js_service3 = require("@e22m4u/js-service");
|
|
|
var import_js_format7 = require("@e22m4u/js-format");
|
|
var import_js_format7 = require("@e22m4u/js-format");
|
|
|
|
|
|
|
|
// src/data-schema-resolver.js
|
|
// src/data-schema-resolver.js
|
|
@@ -311,9 +311,6 @@ var DataSchemaResolver = class extends import_js_service2.Service {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-// src/data-validators/array-type-validator.js
|
|
|
|
|
-var import_js_service3 = require("@e22m4u/js-service");
|
|
|
|
|
-
|
|
|
|
|
// src/utils/to-pascal-case.js
|
|
// src/utils/to-pascal-case.js
|
|
|
function toPascalCase(input) {
|
|
function toPascalCase(input) {
|
|
|
if (!input) return "";
|
|
if (!input) return "";
|
|
@@ -381,14 +378,11 @@ var DataValidationError = class extends import_js_format6.InvalidArgumentError {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// src/data-validators/array-type-validator.js
|
|
// src/data-validators/array-type-validator.js
|
|
|
-var import_js_empty_values = require("@e22m4u/js-empty-values");
|
|
|
|
|
-function arrayTypeValidator(value, schema, options, container) {
|
|
|
|
|
|
|
+function arrayTypeValidator(value, schema, options) {
|
|
|
if (schema.type !== DataType.ARRAY) {
|
|
if (schema.type !== DataType.ARRAY) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- const emptyValues = container.get(import_js_empty_values.EmptyValuesService);
|
|
|
|
|
- const dataType = schema.type || DataType.ANY;
|
|
|
|
|
- if (emptyValues.isEmptyOf(dataType, value)) {
|
|
|
|
|
|
|
+ if (value == null) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
if (Array.isArray(value)) {
|
|
if (Array.isArray(value)) {
|
|
@@ -411,15 +405,11 @@ function arrayTypeValidator(value, schema, options, container) {
|
|
|
__name(arrayTypeValidator, "arrayTypeValidator");
|
|
__name(arrayTypeValidator, "arrayTypeValidator");
|
|
|
|
|
|
|
|
// src/data-validators/object-type-validator.js
|
|
// src/data-validators/object-type-validator.js
|
|
|
-var import_js_service4 = require("@e22m4u/js-service");
|
|
|
|
|
-var import_js_empty_values2 = require("@e22m4u/js-empty-values");
|
|
|
|
|
-function objectTypeValidator(value, schema, options, container) {
|
|
|
|
|
|
|
+function objectTypeValidator(value, schema, options) {
|
|
|
if (schema.type !== DataType.OBJECT) {
|
|
if (schema.type !== DataType.OBJECT) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- const emptyValues = container.get(import_js_empty_values2.EmptyValuesService);
|
|
|
|
|
- const dataType = schema.type || DataType.ANY;
|
|
|
|
|
- if (emptyValues.isEmptyOf(dataType, value)) {
|
|
|
|
|
|
|
+ if (value == null) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
@@ -442,15 +432,11 @@ function objectTypeValidator(value, schema, options, container) {
|
|
|
__name(objectTypeValidator, "objectTypeValidator");
|
|
__name(objectTypeValidator, "objectTypeValidator");
|
|
|
|
|
|
|
|
// src/data-validators/string-type-validator.js
|
|
// src/data-validators/string-type-validator.js
|
|
|
-var import_js_service5 = require("@e22m4u/js-service");
|
|
|
|
|
-var import_js_empty_values3 = require("@e22m4u/js-empty-values");
|
|
|
|
|
-function stringTypeValidator(value, schema, options, container) {
|
|
|
|
|
|
|
+function stringTypeValidator(value, schema, options) {
|
|
|
if (schema.type !== DataType.STRING) {
|
|
if (schema.type !== DataType.STRING) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- const emptyValues = container.get(import_js_empty_values3.EmptyValuesService);
|
|
|
|
|
- const dataType = schema.type || DataType.ANY;
|
|
|
|
|
- if (emptyValues.isEmptyOf(dataType, value)) {
|
|
|
|
|
|
|
+ if (value == null) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
if (typeof value === "string") {
|
|
if (typeof value === "string") {
|
|
@@ -473,15 +459,11 @@ function stringTypeValidator(value, schema, options, container) {
|
|
|
__name(stringTypeValidator, "stringTypeValidator");
|
|
__name(stringTypeValidator, "stringTypeValidator");
|
|
|
|
|
|
|
|
// src/data-validators/number-type-validator.js
|
|
// src/data-validators/number-type-validator.js
|
|
|
-var import_js_service6 = require("@e22m4u/js-service");
|
|
|
|
|
-var import_js_empty_values4 = require("@e22m4u/js-empty-values");
|
|
|
|
|
-function numberTypeValidator(value, schema, options, container) {
|
|
|
|
|
|
|
+function numberTypeValidator(value, schema, options) {
|
|
|
if (schema.type !== DataType.NUMBER) {
|
|
if (schema.type !== DataType.NUMBER) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- const emptyValues = container.get(import_js_empty_values4.EmptyValuesService);
|
|
|
|
|
- const dataType = schema.type || DataType.ANY;
|
|
|
|
|
- if (emptyValues.isEmptyOf(dataType, value)) {
|
|
|
|
|
|
|
+ if (value == null) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
if (typeof value === "number") {
|
|
if (typeof value === "number") {
|
|
@@ -504,15 +486,11 @@ function numberTypeValidator(value, schema, options, container) {
|
|
|
__name(numberTypeValidator, "numberTypeValidator");
|
|
__name(numberTypeValidator, "numberTypeValidator");
|
|
|
|
|
|
|
|
// src/data-validators/boolean-type-validator.js
|
|
// src/data-validators/boolean-type-validator.js
|
|
|
-var import_js_service7 = require("@e22m4u/js-service");
|
|
|
|
|
-var import_js_empty_values5 = require("@e22m4u/js-empty-values");
|
|
|
|
|
-function booleanTypeValidator(value, schema, options, container) {
|
|
|
|
|
|
|
+function booleanTypeValidator(value, schema, options) {
|
|
|
if (schema.type !== DataType.BOOLEAN) {
|
|
if (schema.type !== DataType.BOOLEAN) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- const emptyValues = container.get(import_js_empty_values5.EmptyValuesService);
|
|
|
|
|
- const dataType = schema.type || DataType.ANY;
|
|
|
|
|
- if (emptyValues.isEmptyOf(dataType, value)) {
|
|
|
|
|
|
|
+ if (value == null) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
if (typeof value === "boolean") {
|
|
if (typeof value === "boolean") {
|
|
@@ -535,15 +513,11 @@ function booleanTypeValidator(value, schema, options, container) {
|
|
|
__name(booleanTypeValidator, "booleanTypeValidator");
|
|
__name(booleanTypeValidator, "booleanTypeValidator");
|
|
|
|
|
|
|
|
// src/data-validators/required-value-validator.js
|
|
// src/data-validators/required-value-validator.js
|
|
|
-var import_js_service8 = require("@e22m4u/js-service");
|
|
|
|
|
-var import_js_empty_values6 = require("@e22m4u/js-empty-values");
|
|
|
|
|
-function requiredValueValidator(value, schema, options, container) {
|
|
|
|
|
|
|
+function requiredValueValidator(value, schema, options) {
|
|
|
if (schema.required !== true) {
|
|
if (schema.required !== true) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- const emptyValues = container.get(import_js_empty_values6.EmptyValuesService);
|
|
|
|
|
- const dataType = schema.type || DataType.ANY;
|
|
|
|
|
- if (!emptyValues.isEmptyOf(dataType, value)) {
|
|
|
|
|
|
|
+ if (value != null) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
const sourcePath = options && options.sourcePath;
|
|
const sourcePath = options && options.sourcePath;
|
|
@@ -563,7 +537,7 @@ function requiredValueValidator(value, schema, options, container) {
|
|
|
__name(requiredValueValidator, "requiredValueValidator");
|
|
__name(requiredValueValidator, "requiredValueValidator");
|
|
|
|
|
|
|
|
// src/data-validator.js
|
|
// src/data-validator.js
|
|
|
-var DataValidator = class extends import_js_service9.Service {
|
|
|
|
|
|
|
+var DataValidator = class extends import_js_service3.Service {
|
|
|
static {
|
|
static {
|
|
|
__name(this, "DataValidator");
|
|
__name(this, "DataValidator");
|
|
|
}
|
|
}
|
|
@@ -721,9 +695,7 @@ var DataValidator = class extends import_js_service9.Service {
|
|
|
var import_js_format8 = require("@e22m4u/js-format");
|
|
var import_js_format8 = require("@e22m4u/js-format");
|
|
|
|
|
|
|
|
// src/data-parsers/array-type-parser.js
|
|
// src/data-parsers/array-type-parser.js
|
|
|
-var import_js_service10 = require("@e22m4u/js-service");
|
|
|
|
|
-var import_js_empty_values7 = require("@e22m4u/js-empty-values");
|
|
|
|
|
-function arrayTypeParser(value, schema, options, container) {
|
|
|
|
|
|
|
+function arrayTypeParser(value, schema, options) {
|
|
|
if (schema.type !== DataType.ARRAY) {
|
|
if (schema.type !== DataType.ARRAY) {
|
|
|
return value;
|
|
return value;
|
|
|
}
|
|
}
|
|
@@ -741,13 +713,12 @@ function arrayTypeParser(value, schema, options, container) {
|
|
|
return newValue;
|
|
return newValue;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- const dataType = schema.type || DataType.ANY;
|
|
|
|
|
- const emptyValues = container.get(import_js_empty_values7.EmptyValuesService);
|
|
|
|
|
- if (emptyValues.isEmptyOf(dataType, value)) {
|
|
|
|
|
|
|
+ if (value == null) {
|
|
|
return value;
|
|
return value;
|
|
|
}
|
|
}
|
|
|
if (!options || !options.noParsingErrors) {
|
|
if (!options || !options.noParsingErrors) {
|
|
|
const sourcePath = options && options.sourcePath;
|
|
const sourcePath = options && options.sourcePath;
|
|
|
|
|
+ const dataType = schema.type || DataType.ANY;
|
|
|
throw new DataParsingError(value, dataType, sourcePath);
|
|
throw new DataParsingError(value, dataType, sourcePath);
|
|
|
}
|
|
}
|
|
|
return value;
|
|
return value;
|
|
@@ -755,9 +726,7 @@ function arrayTypeParser(value, schema, options, container) {
|
|
|
__name(arrayTypeParser, "arrayTypeParser");
|
|
__name(arrayTypeParser, "arrayTypeParser");
|
|
|
|
|
|
|
|
// src/data-parsers/string-type-parser.js
|
|
// src/data-parsers/string-type-parser.js
|
|
|
-var import_js_service11 = require("@e22m4u/js-service");
|
|
|
|
|
-var import_js_empty_values8 = require("@e22m4u/js-empty-values");
|
|
|
|
|
-function stringTypeParser(value, schema, options, container) {
|
|
|
|
|
|
|
+function stringTypeParser(value, schema, options) {
|
|
|
if (schema.type !== DataType.STRING) {
|
|
if (schema.type !== DataType.STRING) {
|
|
|
return value;
|
|
return value;
|
|
|
}
|
|
}
|
|
@@ -767,13 +736,12 @@ function stringTypeParser(value, schema, options, container) {
|
|
|
if (typeof value === "number") {
|
|
if (typeof value === "number") {
|
|
|
return String(value);
|
|
return String(value);
|
|
|
}
|
|
}
|
|
|
- const dataType = schema.type || DataType.ANY;
|
|
|
|
|
- const emptyValues = container.get(import_js_empty_values8.EmptyValuesService);
|
|
|
|
|
- if (emptyValues.isEmptyOf(dataType, value)) {
|
|
|
|
|
|
|
+ if (value == null) {
|
|
|
return value;
|
|
return value;
|
|
|
}
|
|
}
|
|
|
if (!options || !options.noParsingErrors) {
|
|
if (!options || !options.noParsingErrors) {
|
|
|
const sourcePath = options && options.sourcePath;
|
|
const sourcePath = options && options.sourcePath;
|
|
|
|
|
+ const dataType = schema.type || DataType.ANY;
|
|
|
throw new DataParsingError(value, dataType, sourcePath);
|
|
throw new DataParsingError(value, dataType, sourcePath);
|
|
|
}
|
|
}
|
|
|
return value;
|
|
return value;
|
|
@@ -781,16 +749,14 @@ function stringTypeParser(value, schema, options, container) {
|
|
|
__name(stringTypeParser, "stringTypeParser");
|
|
__name(stringTypeParser, "stringTypeParser");
|
|
|
|
|
|
|
|
// src/data-parsers/number-type-parser.js
|
|
// src/data-parsers/number-type-parser.js
|
|
|
-var import_js_service12 = require("@e22m4u/js-service");
|
|
|
|
|
-var import_js_empty_values9 = require("@e22m4u/js-empty-values");
|
|
|
|
|
-function numberTypeParser(value, schema, options, container) {
|
|
|
|
|
|
|
+function numberTypeParser(value, schema, options) {
|
|
|
if (schema.type !== DataType.NUMBER) {
|
|
if (schema.type !== DataType.NUMBER) {
|
|
|
return value;
|
|
return value;
|
|
|
}
|
|
}
|
|
|
if (typeof value === "number") {
|
|
if (typeof value === "number") {
|
|
|
return value;
|
|
return value;
|
|
|
}
|
|
}
|
|
|
- if (value && typeof value === "string") {
|
|
|
|
|
|
|
+ if (typeof value === "string" && value.trim() !== "") {
|
|
|
if (value.length <= 20) {
|
|
if (value.length <= 20) {
|
|
|
const newValue = Number(value.trim());
|
|
const newValue = Number(value.trim());
|
|
|
if (!isNaN(newValue)) {
|
|
if (!isNaN(newValue)) {
|
|
@@ -798,13 +764,12 @@ function numberTypeParser(value, schema, options, container) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- const dataType = schema.type || DataType.ANY;
|
|
|
|
|
- const emptyValues = container.get(import_js_empty_values9.EmptyValuesService);
|
|
|
|
|
- if (emptyValues.isEmptyOf(dataType, value)) {
|
|
|
|
|
|
|
+ if (value == null) {
|
|
|
return value;
|
|
return value;
|
|
|
}
|
|
}
|
|
|
if (!options || !options.noParsingErrors) {
|
|
if (!options || !options.noParsingErrors) {
|
|
|
const sourcePath = options && options.sourcePath;
|
|
const sourcePath = options && options.sourcePath;
|
|
|
|
|
+ const dataType = schema.type || DataType.ANY;
|
|
|
throw new DataParsingError(value, dataType, sourcePath);
|
|
throw new DataParsingError(value, dataType, sourcePath);
|
|
|
}
|
|
}
|
|
|
return value;
|
|
return value;
|
|
@@ -812,9 +777,7 @@ function numberTypeParser(value, schema, options, container) {
|
|
|
__name(numberTypeParser, "numberTypeParser");
|
|
__name(numberTypeParser, "numberTypeParser");
|
|
|
|
|
|
|
|
// src/data-parsers/object-type-parser.js
|
|
// src/data-parsers/object-type-parser.js
|
|
|
-var import_js_service13 = require("@e22m4u/js-service");
|
|
|
|
|
-var import_js_empty_values10 = require("@e22m4u/js-empty-values");
|
|
|
|
|
-function objectTypeParser(value, schema, options, container) {
|
|
|
|
|
|
|
+function objectTypeParser(value, schema, options) {
|
|
|
if (schema.type !== DataType.OBJECT) {
|
|
if (schema.type !== DataType.OBJECT) {
|
|
|
return value;
|
|
return value;
|
|
|
}
|
|
}
|
|
@@ -832,13 +795,12 @@ function objectTypeParser(value, schema, options, container) {
|
|
|
return newValue;
|
|
return newValue;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- const dataType = schema.type || DataType.ANY;
|
|
|
|
|
- const emptyValues = container.get(import_js_empty_values10.EmptyValuesService);
|
|
|
|
|
- if (emptyValues.isEmptyOf(dataType, value)) {
|
|
|
|
|
|
|
+ if (value == null) {
|
|
|
return value;
|
|
return value;
|
|
|
}
|
|
}
|
|
|
if (!options || !options.noParsingErrors) {
|
|
if (!options || !options.noParsingErrors) {
|
|
|
const sourcePath = options && options.sourcePath;
|
|
const sourcePath = options && options.sourcePath;
|
|
|
|
|
+ const dataType = schema.type || DataType.ANY;
|
|
|
throw new DataParsingError(value, dataType, sourcePath);
|
|
throw new DataParsingError(value, dataType, sourcePath);
|
|
|
}
|
|
}
|
|
|
return value;
|
|
return value;
|
|
@@ -846,9 +808,7 @@ function objectTypeParser(value, schema, options, container) {
|
|
|
__name(objectTypeParser, "objectTypeParser");
|
|
__name(objectTypeParser, "objectTypeParser");
|
|
|
|
|
|
|
|
// src/data-parsers/boolean-type-parser.js
|
|
// src/data-parsers/boolean-type-parser.js
|
|
|
-var import_js_service14 = require("@e22m4u/js-service");
|
|
|
|
|
-var import_js_empty_values11 = require("@e22m4u/js-empty-values");
|
|
|
|
|
-function booleanTypeParser(value, schema, options, container) {
|
|
|
|
|
|
|
+function booleanTypeParser(value, schema, options) {
|
|
|
if (schema.type !== DataType.BOOLEAN) {
|
|
if (schema.type !== DataType.BOOLEAN) {
|
|
|
return value;
|
|
return value;
|
|
|
}
|
|
}
|
|
@@ -865,13 +825,12 @@ function booleanTypeParser(value, schema, options, container) {
|
|
|
if (value === 1) return true;
|
|
if (value === 1) return true;
|
|
|
if (value === 0) return false;
|
|
if (value === 0) return false;
|
|
|
}
|
|
}
|
|
|
- const dataType = schema.type || DataType.ANY;
|
|
|
|
|
- const emptyValues = container.get(import_js_empty_values11.EmptyValuesService);
|
|
|
|
|
- if (emptyValues.isEmptyOf(dataType, value)) {
|
|
|
|
|
|
|
+ if (value == null) {
|
|
|
return value;
|
|
return value;
|
|
|
}
|
|
}
|
|
|
if (!options || !options.noParsingErrors) {
|
|
if (!options || !options.noParsingErrors) {
|
|
|
const sourcePath = options && options.sourcePath;
|
|
const sourcePath = options && options.sourcePath;
|
|
|
|
|
+ const dataType = schema.type || DataType.ANY;
|
|
|
throw new DataParsingError(value, dataType, sourcePath);
|
|
throw new DataParsingError(value, dataType, sourcePath);
|
|
|
}
|
|
}
|
|
|
return value;
|
|
return value;
|
|
@@ -879,8 +838,7 @@ function booleanTypeParser(value, schema, options, container) {
|
|
|
__name(booleanTypeParser, "booleanTypeParser");
|
|
__name(booleanTypeParser, "booleanTypeParser");
|
|
|
|
|
|
|
|
// src/data-parsers/default-value-setter.js
|
|
// src/data-parsers/default-value-setter.js
|
|
|
-var import_js_service15 = require("@e22m4u/js-service");
|
|
|
|
|
-var import_js_empty_values12 = require("@e22m4u/js-empty-values");
|
|
|
|
|
|
|
+var import_js_service4 = require("@e22m4u/js-service");
|
|
|
function defaultValueSetter(value, schema, options, container) {
|
|
function defaultValueSetter(value, schema, options, container) {
|
|
|
if (options && options.noDefaultValues) {
|
|
if (options && options.noDefaultValues) {
|
|
|
return value;
|
|
return value;
|
|
@@ -888,9 +846,7 @@ function defaultValueSetter(value, schema, options, container) {
|
|
|
if (schema.default === void 0) {
|
|
if (schema.default === void 0) {
|
|
|
return value;
|
|
return value;
|
|
|
}
|
|
}
|
|
|
- const emptyValues = container.get(import_js_empty_values12.EmptyValuesService);
|
|
|
|
|
- const dataType = schema.type || DataType.ANY;
|
|
|
|
|
- if (!emptyValues.isEmptyOf(dataType, value)) {
|
|
|
|
|
|
|
+ if (value != null) {
|
|
|
return value;
|
|
return value;
|
|
|
}
|
|
}
|
|
|
if (typeof schema.default === "function") {
|
|
if (typeof schema.default === "function") {
|
|
@@ -901,7 +857,7 @@ function defaultValueSetter(value, schema, options, container) {
|
|
|
__name(defaultValueSetter, "defaultValueSetter");
|
|
__name(defaultValueSetter, "defaultValueSetter");
|
|
|
|
|
|
|
|
// src/data-parser.js
|
|
// src/data-parser.js
|
|
|
-var DataParser = class extends import_js_service16.Service {
|
|
|
|
|
|
|
+var DataParser = class extends import_js_service5.Service {
|
|
|
static {
|
|
static {
|
|
|
__name(this, "DataParser");
|
|
__name(this, "DataParser");
|
|
|
}
|
|
}
|