Comparing version 1.3.5 to 1.3.6
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -7,5 +17,10 @@ /** | ||
*/ | ||
class DateClass extends Date { | ||
} | ||
DateClass.type = "DateClass"; | ||
var DateClass = /** @class */ (function (_super) { | ||
__extends(DateClass, _super); | ||
function DateClass() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
DateClass.type = "DateClass"; | ||
return DateClass; | ||
}(Date)); | ||
exports.DateClass = DateClass; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class GenericTypes { | ||
var GenericTypes = /** @class */ (function () { | ||
/*tslint:disable no-any*/ | ||
constructor(types) { | ||
function GenericTypes(types) { | ||
this.types = types; | ||
} | ||
} | ||
return GenericTypes; | ||
}()); | ||
exports.GenericTypes = GenericTypes; |
@@ -11,4 +11,4 @@ "use strict"; | ||
})(JsonParseErrorCode = exports.JsonParseErrorCode || (exports.JsonParseErrorCode = {})); | ||
class JsonParseError { | ||
constructor(message, parseCode) { | ||
var JsonParseError = /** @class */ (function () { | ||
function JsonParseError(message, parseCode) { | ||
this.message = message; | ||
@@ -18,6 +18,7 @@ this.parseCode = parseCode; | ||
} | ||
toString() { | ||
JsonParseError.prototype.toString = function () { | ||
return "JsonParseError: " + this.message; | ||
} | ||
} | ||
}; | ||
return JsonParseError; | ||
}()); | ||
exports.JsonParseError = JsonParseError; |
@@ -13,10 +13,10 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const lodash_zip_1 = __importDefault(require("lodash.zip")); | ||
const JsonParseError_1 = require("./JsonParseError"); | ||
const dateUtils = __importStar(require("../utils/DateUtils")); | ||
var lodash_times_1 = __importDefault(require("lodash.times")); | ||
var lodash_zip_1 = __importDefault(require("lodash.zip")); | ||
var JsonParseError_1 = require("./JsonParseError"); | ||
var dateUtils = __importStar(require("../utils/DateUtils")); | ||
require("reflect-metadata"); | ||
/*tslint:disable no-any*/ | ||
const mapperRegister = {}; | ||
const times = (value) => [...Array(value).keys()]; | ||
const clone = (array) => [...array]; | ||
var mapperRegister = {}; | ||
var clone = function (array) { return array.slice(); }; | ||
function registerStringMapper(type, mapper) { | ||
@@ -36,10 +36,10 @@ mapperRegister[getName(type) + "_string"] = mapper; | ||
if (matchesType(jsonValue)) { | ||
const value = convert(jsonValue); | ||
validators.forEach(validator => { | ||
const err = validator(value); | ||
var value_1 = convert(jsonValue); | ||
validators.forEach(function (validator) { | ||
var err = validator(value_1); | ||
if (err) { | ||
throw new JsonParseError_1.JsonParseError(`Validation failed for property: ${propName}: ${err}`, JsonParseError_1.JsonParseErrorCode.VALIDATION_FAILED); | ||
throw new JsonParseError_1.JsonParseError("Validation failed for property: " + propName + ": " + err, JsonParseError_1.JsonParseErrorCode.VALIDATION_FAILED); | ||
} | ||
}); | ||
return value; | ||
return value_1; | ||
} | ||
@@ -55,14 +55,14 @@ throw error(); | ||
} | ||
const expectedTypeName = getName(cls); | ||
var expectedTypeName = getName(cls); | ||
switch (expectedTypeName) { | ||
case "String": | ||
return tryReadField(json, fieldValue => typeof fieldValue === "string", fieldValue => fieldValue, () => new JsonParseError_1.JsonParseError("Expected a string value for property " + propName(), JsonParseError_1.JsonParseErrorCode.INVALID_TYPE), validators, propName()); | ||
return tryReadField(json, function (fieldValue) { return typeof fieldValue === "string"; }, function (fieldValue) { return fieldValue; }, function () { return new JsonParseError_1.JsonParseError("Expected a string value for property " + propName(), JsonParseError_1.JsonParseErrorCode.INVALID_TYPE); }, validators, propName()); | ||
case "Number": | ||
return tryReadField(json, fieldValue => typeof fieldValue === "number", fieldValue => fieldValue, () => new JsonParseError_1.JsonParseError("Expected a number value for property " + propName(), JsonParseError_1.JsonParseErrorCode.INVALID_TYPE), validators, propName()); | ||
return tryReadField(json, function (fieldValue) { return typeof fieldValue === "number"; }, function (fieldValue) { return fieldValue; }, function () { return new JsonParseError_1.JsonParseError("Expected a number value for property " + propName(), JsonParseError_1.JsonParseErrorCode.INVALID_TYPE); }, validators, propName()); | ||
case "Boolean": | ||
return tryReadField(json, fieldValue => typeof fieldValue === "boolean", fieldValue => fieldValue, () => new JsonParseError_1.JsonParseError("Expected a boolean value for property " + propName(), JsonParseError_1.JsonParseErrorCode.INVALID_TYPE), validators, propName()); | ||
return tryReadField(json, function (fieldValue) { return typeof fieldValue === "boolean"; }, function (fieldValue) { return fieldValue; }, function () { return new JsonParseError_1.JsonParseError("Expected a boolean value for property " + propName(), JsonParseError_1.JsonParseErrorCode.INVALID_TYPE); }, validators, propName()); | ||
case "DateClass": | ||
const isoRegexp = /(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+)|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d)|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d)/; | ||
const regExp = /(\d{4})-(\d{2})(?:-(\d{2}))/; | ||
return tryReadField(json, dateUtils.isDateString, dateUtils.parseDate, () => new JsonParseError_1.JsonParseError("Expected a Date object for property " + propName(), JsonParseError_1.JsonParseErrorCode.INVALID_TYPE), validators, propName()); | ||
var isoRegexp = /(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+)|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d)|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d)/; | ||
var regExp = /(\d{4})-(\d{2})(?:-(\d{2}))/; | ||
return tryReadField(json, dateUtils.isDateString, dateUtils.parseDate, function () { return new JsonParseError_1.JsonParseError("Expected a Date object for property " + propName(), JsonParseError_1.JsonParseErrorCode.INVALID_TYPE); }, validators, propName()); | ||
case "Array": | ||
@@ -72,3 +72,3 @@ if (!spec.type) { | ||
} | ||
return tryReadField(json, fieldValue => Array.isArray(fieldValue), fieldValue => fieldValue.map((arrayElem, idx) => parseValue(spec.type, arrayElem, { propName: "[" + idx + "]", optional: false, defaultValue: undefined }, prefix + "/" + spec.propName, genericTypes, validators)), () => new JsonParseError_1.JsonParseError("Expected an array for property " + propName(), JsonParseError_1.JsonParseErrorCode.INVALID_TYPE), validators, propName()); | ||
return tryReadField(json, function (fieldValue) { return Array.isArray(fieldValue); }, function (fieldValue) { return fieldValue.map(function (arrayElem, idx) { return parseValue(spec.type, arrayElem, { propName: "[" + idx + "]", optional: false, defaultValue: undefined }, prefix + "/" + spec.propName, genericTypes, validators); }); }, function () { return new JsonParseError_1.JsonParseError("Expected an array for property " + propName(), JsonParseError_1.JsonParseErrorCode.INVALID_TYPE); }, validators, propName()); | ||
default: | ||
@@ -79,19 +79,19 @@ return doParse(cls, json, prefix + "/" + spec.propName, genericTypes); | ||
function doParse(cls, json, prefix, genericTypes) { | ||
let getMetadata = Reflect.getMetadata; | ||
var getMetadata = Reflect.getMetadata; | ||
if (isSimpleType(cls)) { | ||
return parseValue(cls, json, { propName: "array", type: cls, optional: true, defaultValue: undefined }, prefix, undefined, []); | ||
} | ||
let constructorParams = clone(getMetadata("design:paramtypes", cls)); | ||
var constructorParams = clone(getMetadata("design:paramtypes", cls)); | ||
if (!constructorParams || isRegistrable(cls)) { | ||
const clsName = getName(cls); | ||
const mapperKey = clsName + "_" + typeof json; | ||
var clsName = getName(cls); | ||
var mapperKey = clsName + "_" + typeof json; | ||
if (mapperRegister[mapperKey]) { | ||
return mapperRegister[mapperKey](json); | ||
} | ||
throw new JsonParseError_1.JsonParseError(`No mapper defined for types ${clsName} and ${typeof json}`, JsonParseError_1.JsonParseErrorCode.INVALID_MODEL_CLASS); | ||
throw new JsonParseError_1.JsonParseError("No mapper defined for types " + clsName + " and " + typeof json, JsonParseError_1.JsonParseErrorCode.INVALID_MODEL_CLASS); | ||
} | ||
let jsonProps = times(constructorParams.length).map(n => getMetadata("field:" + n, cls)); | ||
var jsonProps = lodash_times_1.default(constructorParams.length).map(function (n) { return getMetadata("field:" + n, cls); }); | ||
if (genericTypes) { | ||
jsonProps.forEach((prop, n) => { | ||
let spec = prop; | ||
jsonProps.forEach(function (prop, n) { | ||
var spec = prop; | ||
if (genericTypes.types[spec.propName] && constructorParams[n] === Object) { | ||
@@ -102,10 +102,10 @@ constructorParams[n] = genericTypes.types[spec.propName]; | ||
} | ||
let copyParams = getMetadata("design:paramtypes", cls); | ||
let generics = times(constructorParams.length).map(n => getGenericMetadata(jsonProps, n, cls, getMetadata)); | ||
let validators = times(constructorParams.length).map(n => getMetadata("validation:" + n, cls)); | ||
let values = lodash_zip_1.default(jsonProps, constructorParams, generics, validators).map(data => { | ||
let spec = data[0]; | ||
let param = data[1]; | ||
let genericTypes = data[2]; | ||
let validators = data[3]; | ||
var copyParams = getMetadata("design:paramtypes", cls); | ||
var generics = lodash_times_1.default(constructorParams.length).map(function (n) { return getGenericMetadata(jsonProps, n, cls, getMetadata); }); | ||
var validators = lodash_times_1.default(constructorParams.length).map(function (n) { return getMetadata("validation:" + n, cls); }); | ||
var values = lodash_zip_1.default(jsonProps, constructorParams, generics, validators).map(function (data) { | ||
var spec = data[0]; | ||
var param = data[1]; | ||
var genericTypes = data[2]; | ||
var validators = data[3]; | ||
if (!spec || !spec.propName) { | ||
@@ -115,5 +115,5 @@ throw new JsonParseError_1.JsonParseError("Missing @Field annotation in type " + getName(cls), JsonParseError_1.JsonParseErrorCode.MISSING_ANNOTATION); | ||
//support for variant names like "foo | bar | baz" | ||
const propNames = spec.propName.split("|").map(p => p.trim()); | ||
let innerJson = undefined; | ||
for (let i = 0; i < propNames.length; i++) { | ||
var propNames = spec.propName.split("|").map(function (p) { return p.trim(); }); | ||
var innerJson = undefined; | ||
for (var i = 0; i < propNames.length; i++) { | ||
if (json.hasOwnProperty(propNames[i])) { | ||
@@ -132,3 +132,3 @@ innerJson = json[propNames[i]]; | ||
}); | ||
return new cls(...values); | ||
return new (cls.bind.apply(cls, [void 0].concat(values)))(); | ||
} | ||
@@ -141,4 +141,4 @@ function getGenericMetadata(props, index, cls, getMetadata) { | ||
function getName(cls) { | ||
let getMetadata = Reflect.getMetadata; | ||
const sparksonId = getMetadata("sparksonRegistrable", cls); | ||
var getMetadata = Reflect.getMetadata; | ||
var sparksonId = getMetadata("sparksonRegistrable", cls); | ||
if (sparksonId) { | ||
@@ -158,8 +158,8 @@ return sparksonId; | ||
function isSimpleType(cls) { | ||
let typeName = getName(cls); | ||
var typeName = getName(cls); | ||
return typeName === "String" || typeName === "Number" || typeName === "Boolean" || typeName == "DateClass"; | ||
} | ||
function isRegistrable(cls) { | ||
let getMetadata = Reflect.getMetadata; | ||
const sparksonId = getMetadata("sparksonRegistrable", cls); | ||
var getMetadata = Reflect.getMetadata; | ||
var sparksonId = getMetadata("sparksonRegistrable", cls); | ||
return !!sparksonId; | ||
@@ -171,3 +171,4 @@ } | ||
exports.parse = parse; | ||
function parseArray(cls, json, optional = false) { | ||
function parseArray(cls, json, optional) { | ||
if (optional === void 0) { optional = false; } | ||
if (json === null && optional) { | ||
@@ -174,0 +175,0 @@ return []; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/*tslint:disable no-any*/ | ||
function ArrayField(jsonProperty, type, optional = false, genericTypes = null) { | ||
return (target, propertyKey, parameterIndex) => { | ||
function ArrayField(jsonProperty, type, optional, genericTypes) { | ||
if (optional === void 0) { optional = false; } | ||
if (genericTypes === void 0) { genericTypes = null; } | ||
return function (target, propertyKey, parameterIndex) { | ||
Reflect.defineMetadata("field:" + parameterIndex, { propName: jsonProperty, type: type, optional: optional }, target); | ||
if (genericTypes) { | ||
Object.keys(genericTypes.types).forEach(id => { | ||
Object.keys(genericTypes.types).forEach(function (id) { | ||
Reflect.defineMetadata("generic:" + jsonProperty, genericTypes, target); | ||
@@ -10,0 +12,0 @@ }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function Field(jsonProperty, optional = false, genericTypes = null, defaultValue = undefined) { | ||
return (target, propertyKey, parameterIndex) => { | ||
function Field(jsonProperty, optional, genericTypes, defaultValue) { | ||
if (optional === void 0) { optional = false; } | ||
if (genericTypes === void 0) { genericTypes = null; } | ||
if (defaultValue === void 0) { defaultValue = undefined; } | ||
return function (target, propertyKey, parameterIndex) { | ||
/*tslint:disable no-any*/ | ||
Reflect.defineMetadata("field:" + parameterIndex, { propName: jsonProperty, optional: optional, defaultValue: defaultValue }, target); | ||
if (genericTypes) { | ||
Object.keys(genericTypes.types).forEach(id => { | ||
Object.keys(genericTypes.types).forEach(function (id) { | ||
Reflect.defineMetadata("generic:" + jsonProperty, genericTypes, target); | ||
@@ -10,0 +13,0 @@ }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function RawJsonField(jsonProperty, optional = false, defaultValue = undefined) { | ||
return (target, propertyKey, parameterIndex) => { | ||
function RawJsonField(jsonProperty, optional, defaultValue) { | ||
if (optional === void 0) { optional = false; } | ||
if (defaultValue === void 0) { defaultValue = undefined; } | ||
return function (target, propertyKey, parameterIndex) { | ||
/*tslint:disable no-any*/ | ||
@@ -6,0 +8,0 @@ Reflect.defineMetadata("field:" + parameterIndex, { propName: jsonProperty, optional: optional, rawValue: true, defaultValue: defaultValue }, target); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
require("reflect-metadata"); | ||
const RANGE = 10000000; | ||
var RANGE = 10000000; | ||
function Registrable(ctor) { | ||
const sid = Math.floor(Math.random() * RANGE + 1).toString(); | ||
var sid = Math.floor(Math.random() * RANGE + 1).toString(); | ||
Reflect.defineMetadata("sparksonRegistrable", sid, ctor); | ||
@@ -8,0 +8,0 @@ return undefined; |
@@ -10,8 +10,8 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ValidationHelper_1 = require("./ValidationHelper"); | ||
const dateUtils = __importStar(require("../../utils/DateUtils")); | ||
var ValidationHelper_1 = require("./ValidationHelper"); | ||
var dateUtils = __importStar(require("../../utils/DateUtils")); | ||
function After(value) { | ||
return (target, propertyKey, parameterIndex) => { | ||
const afterValidator = (fieldValue) => { | ||
let valueDate = null; | ||
return function (target, propertyKey, parameterIndex) { | ||
var afterValidator = function (fieldValue) { | ||
var valueDate = null; | ||
if (value instanceof Date) { | ||
@@ -24,3 +24,3 @@ valueDate = value; | ||
if (fieldValue.getTime !== undefined && fieldValue.getTime() <= valueDate.getTime()) { | ||
return `Value must be after ${value}`; | ||
return "Value must be after " + value; | ||
} | ||
@@ -27,0 +27,0 @@ return null; |
@@ -10,8 +10,8 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ValidationHelper_1 = require("./ValidationHelper"); | ||
const dateUtils = __importStar(require("../../utils/DateUtils")); | ||
var ValidationHelper_1 = require("./ValidationHelper"); | ||
var dateUtils = __importStar(require("../../utils/DateUtils")); | ||
function Before(value) { | ||
return (target, propertyKey, parameterIndex) => { | ||
const beforeValidator = (fieldValue) => { | ||
let valueDate = null; | ||
return function (target, propertyKey, parameterIndex) { | ||
var beforeValidator = function (fieldValue) { | ||
var valueDate = null; | ||
if (value instanceof Date) { | ||
@@ -24,3 +24,3 @@ valueDate = value; | ||
if (fieldValue.getTime !== undefined && fieldValue.getTime() >= valueDate.getTime()) { | ||
return `Value must be before ${value}`; | ||
return "Value must be before " + value; | ||
} | ||
@@ -27,0 +27,0 @@ return null; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ValidationHelper_1 = require("./ValidationHelper"); | ||
var ValidationHelper_1 = require("./ValidationHelper"); | ||
function Max(value) { | ||
return (target, propertyKey, parameterIndex) => { | ||
const maxValidator = (fieldValue) => { | ||
return function (target, propertyKey, parameterIndex) { | ||
var maxValidator = function (fieldValue) { | ||
if (fieldValue > value) { | ||
return `Value cannot be greater than ${value}`; | ||
return "Value cannot be greater than " + value; | ||
} | ||
@@ -10,0 +10,0 @@ return null; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ValidationHelper_1 = require("./ValidationHelper"); | ||
var ValidationHelper_1 = require("./ValidationHelper"); | ||
function MaxLength(value) { | ||
return (target, propertyKey, parameterIndex) => { | ||
const maxLengthValidator = (fieldValue) => { | ||
return function (target, propertyKey, parameterIndex) { | ||
var maxLengthValidator = function (fieldValue) { | ||
if (fieldValue.length !== undefined && fieldValue.length > value) { | ||
return `Value cannot be longer than ${value}`; | ||
return "Value cannot be longer than " + value; | ||
} | ||
@@ -10,0 +10,0 @@ return null; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ValidationHelper_1 = require("./ValidationHelper"); | ||
var ValidationHelper_1 = require("./ValidationHelper"); | ||
function Min(value) { | ||
return (target, propertyKey, parameterIndex) => { | ||
const minValidator = (fieldValue) => { | ||
return function (target, propertyKey, parameterIndex) { | ||
var minValidator = function (fieldValue) { | ||
if (fieldValue < value) { | ||
return `Value cannot be smaller than ${value}`; | ||
return "Value cannot be smaller than " + value; | ||
} | ||
@@ -10,0 +10,0 @@ return null; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ValidationHelper_1 = require("./ValidationHelper"); | ||
var ValidationHelper_1 = require("./ValidationHelper"); | ||
function MinLength(value) { | ||
return (target, propertyKey, parameterIndex) => { | ||
const minLengthValidator = (fieldValue) => { | ||
return function (target, propertyKey, parameterIndex) { | ||
var minLengthValidator = function (fieldValue) { | ||
if (fieldValue.length !== undefined && fieldValue.length < value) { | ||
return `Value cannot be shorter than ${value}`; | ||
return "Value cannot be shorter than " + value; | ||
} | ||
@@ -10,0 +10,0 @@ return null; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ValidationHelper_1 = require("./ValidationHelper"); | ||
var ValidationHelper_1 = require("./ValidationHelper"); | ||
function Regexp(value) { | ||
return (target, propertyKey, parameterIndex) => { | ||
const regexValidator = (fieldValue) => { | ||
return function (target, propertyKey, parameterIndex) { | ||
var regexValidator = function (fieldValue) { | ||
if (!value.test(fieldValue)) { | ||
return `Value must match regular expression ${value}`; | ||
return "Value must match regular expression " + value; | ||
} | ||
@@ -10,0 +10,0 @@ return null; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ValidationHelper_1 = require("./ValidationHelper"); | ||
var ValidationHelper_1 = require("./ValidationHelper"); | ||
function Rule(customRule) { | ||
return (target, propertyKey, parameterIndex) => { | ||
return function (target, propertyKey, parameterIndex) { | ||
ValidationHelper_1.addValidationRule(target, parameterIndex, customRule); | ||
@@ -7,0 +7,0 @@ }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function addValidationRule(target, paramIndex, rule) { | ||
const metaKey = "validation:" + paramIndex; | ||
let validationRules = Reflect.getMetadata(metaKey, target); | ||
var metaKey = "validation:" + paramIndex; | ||
var validationRules = Reflect.getMetadata(metaKey, target); | ||
if (!validationRules) { | ||
@@ -7,0 +7,0 @@ validationRules = []; |
{ | ||
"name": "sparkson", | ||
"version": "1.3.5", | ||
"version": "1.3.6", | ||
"description": "Declarative JSON parsing and validation library for TypeScript", | ||
@@ -28,2 +28,3 @@ "main": "./lib/sparkson.js", | ||
"dependencies": { | ||
"lodash.times": "4.3.2", | ||
"lodash.zip": "4.2.0", | ||
@@ -30,0 +31,0 @@ "reflect-metadata": "0.1.12" |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const isoRegexp = /(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+)|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d)|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d)/; | ||
const regExp = /(\d{4})-(\d{2})(?:-(\d{2}))/; | ||
var isoRegexp = /(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+)|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d)|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d)/; | ||
var regExp = /(\d{4})-(\d{2})(?:-(\d{2}))/; | ||
function isDateString(value) { | ||
@@ -16,3 +16,3 @@ return isoRegexp.test(value) || regExp.test(value); | ||
} | ||
const [, year, month, day] = regExp.exec(value); | ||
var _a = regExp.exec(value), year = _a[1], month = _a[2], day = _a[3]; | ||
if (day !== undefined) { | ||
@@ -19,0 +19,0 @@ return new Date(parseInt(year, 10), parseInt(month, 10) - 1, parseInt(day, 10)); |
{ | ||
"name": "sparkson", | ||
"version": "1.3.5", | ||
"version": "1.3.6", | ||
"description": "Declarative JSON parsing and validation library for TypeScript", | ||
@@ -28,2 +28,3 @@ "main": "./lib/sparkson.js", | ||
"dependencies": { | ||
"lodash.times": "4.3.2", | ||
"lodash.zip": "4.2.0", | ||
@@ -30,0 +31,0 @@ "reflect-metadata": "0.1.12" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
45983
831
0
3
+ Addedlodash.times@4.3.2
+ Addedlodash.times@4.3.2(transitive)