rokot-validate
Advanced tools
Comparing version 0.5.3 to 0.5.4
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t; | ||
return { next: verb(0), "throw": verb(1), "return": verb(2) }; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [0, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var validateJsWithCustomValidators_1 = require("./validateJsWithCustomValidators"); | ||
@@ -198,5 +164,5 @@ var ClientConstraintBuilder = (function () { | ||
var _this = this; | ||
return function (value) { return __awaiter(_this, void 0, void 0, function () { | ||
return function (value) { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
var i, validated, result, _a; | ||
return __generator(this, function (_b) { | ||
return tslib_1.__generator(this, function (_b) { | ||
switch (_b.label) { | ||
@@ -203,0 +169,0 @@ case 0: |
"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 }); | ||
var tslib_1 = require("tslib"); | ||
var Errors; | ||
@@ -21,3 +12,3 @@ (function (Errors) { | ||
var CustomError = (function (_super) { | ||
__extends(CustomError, _super); | ||
tslib_1.__extends(CustomError, _super); | ||
function CustomError(type, message, internalMessage) { | ||
@@ -34,3 +25,3 @@ var _this = _super.call(this) || this; | ||
var ValidationError = (function (_super) { | ||
__extends(ValidationError, _super); | ||
tslib_1.__extends(ValidationError, _super); | ||
function ValidationError(errors) { | ||
@@ -47,3 +38,3 @@ var _this = _super.call(this, ErrorType.ValidationError, "Validation error") || this; | ||
var NoValidationInputError = (function (_super) { | ||
__extends(NoValidationInputError, _super); | ||
tslib_1.__extends(NoValidationInputError, _super); | ||
function NoValidationInputError() { | ||
@@ -50,0 +41,0 @@ var _this = _super.call(this, ErrorType.NoInputError, "No input provided") || this; |
@@ -37,2 +37,3 @@ export interface IValidator<T> { | ||
numericality?: NumericalityConstraint; | ||
string?: Constraint | boolean; | ||
} | ||
@@ -39,0 +40,0 @@ export interface MustConstraint<T> extends Constraint { |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t; | ||
return { next: verb(0), "throw": verb(1), "return": verb(2) }; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [0, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var _this = this; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var moment = require("moment"); | ||
@@ -62,9 +28,17 @@ var validate = require("validate.js"); | ||
} | ||
if (options.numericality) { | ||
var errors = value.map(function (v) { return validate.validators.numericality(v, options.numericality); }).filter(function (r) { return !!r; }); | ||
if (errors.length) { | ||
return errors.map(function (e) { return "array member " + e; }); | ||
if (options === true) { | ||
return; | ||
} | ||
var errors = value.map(function (v, idx) { | ||
var field = "'item " + idx + "'"; | ||
var vr = validate((_a = {}, _a[field] = v, _a), (_b = {}, _b[field] = options, _b)); | ||
if (vr) { | ||
} | ||
; | ||
return vr; | ||
var _a, _b; | ||
}).filter(function (r) { return !!r; }); | ||
if (errors.length) { | ||
return errors.map(function (e) { return Object.keys(e).map(function (k) { return e[k].join(","); }).join(":"); }); | ||
} | ||
; | ||
}; | ||
@@ -94,5 +68,5 @@ validate.validators.arrayNumericality = function (value, options, key, attributes) { | ||
}; | ||
validate.validators.must = function (value, validator, key, attributes) { return __awaiter(_this, void 0, void 0, function () { | ||
validate.validators.must = function (value, validator, key, attributes) { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
var i, result; | ||
return __generator(this, function (_a) { | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
@@ -126,5 +100,5 @@ case 0: | ||
function tryValidate(validator, value, attributes) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var aa, valid, _a; | ||
return __generator(this, function (_b) { | ||
return tslib_1.__generator(this, function (_b) { | ||
switch (_b.label) { | ||
@@ -131,0 +105,0 @@ case 0: |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t; | ||
return { next: verb(0), "throw": verb(1), "return": verb(2) }; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [0, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var validateJsWithCustomValidators_1 = require("./validateJsWithCustomValidators"); | ||
@@ -152,5 +118,5 @@ var errors_1 = require("./errors"); | ||
Validation.execute = function (instance, validation) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var result, errors; | ||
return __generator(this, function (_a) { | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
@@ -175,5 +141,5 @@ case 0: | ||
Validation.getValidationContext = function (spec, instance, key, parentKey) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var ctx; | ||
return __generator(this, function (_a) { | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
@@ -221,5 +187,5 @@ case 0: | ||
Validation.recursivelyValidate = function (visitData, instance, spec, key, parentKey) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var id, stored, context; | ||
return __generator(this, function (_a) { | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
@@ -245,5 +211,5 @@ case 0: | ||
Validation.validateContext = function (visitData, id, validationContext) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var errors, validationResult, results; | ||
return __generator(this, function (_a) { | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
@@ -267,5 +233,5 @@ case 0: return [4 /*yield*/, this.getValidationErrors(validationContext)]; | ||
Validation.getChildValidationResults = function (visitData, validationContext) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var results, keys, i, key, value, spec, idx, arrayKey, ve_1, ve; | ||
return __generator(this, function (_a) { | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
@@ -323,5 +289,5 @@ case 0: | ||
Validation.getValidationErrors = function (validationContext) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var errors_2; | ||
return __generator(this, function (_a) { | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
@@ -328,0 +294,0 @@ case 0: |
"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 }); | ||
var tslib_1 = require("tslib"); | ||
var validation_1 = require("./validation"); | ||
var constraintBuilder_1 = require("./constraintBuilder"); | ||
var ValidatorBase = (function (_super) { | ||
__extends(ValidatorBase, _super); | ||
tslib_1.__extends(ValidatorBase, _super); | ||
function ValidatorBase() { | ||
@@ -27,3 +18,3 @@ return _super !== null && _super.apply(this, arguments) || this; | ||
var Validator = (function (_super) { | ||
__extends(Validator, _super); | ||
tslib_1.__extends(Validator, _super); | ||
function Validator() { | ||
@@ -37,3 +28,3 @@ return _super !== null && _super.apply(this, arguments) || this; | ||
var V = (function (_super) { | ||
__extends(V, _super); | ||
tslib_1.__extends(V, _super); | ||
function V() { | ||
@@ -56,3 +47,3 @@ return _super !== null && _super.apply(this, arguments) || this; | ||
var ValidatorWithContext = (function (_super) { | ||
__extends(ValidatorWithContext, _super); | ||
tslib_1.__extends(ValidatorWithContext, _super); | ||
function ValidatorWithContext() { | ||
@@ -59,0 +50,0 @@ return _super !== null && _super.apply(this, arguments) || this; |
{ | ||
"name": "rokot-validate", | ||
"version": "0.5.3", | ||
"version": "0.5.4", | ||
"description": "Rocketmakers Rokot Platform - Validation", | ||
@@ -9,9 +9,8 @@ "main": "./lib/index.js", | ||
"format": "tsfmt -r source/**/*.ts", | ||
"build": "tsc -p source/tsconfig.json -d", | ||
"prepublish": "npm run build", | ||
"debugtest": "npm run build && ./node_modules/mocha/bin/mocha --debug-brk", | ||
"test": "npm run build && ./node_modules/mocha/bin/mocha" | ||
"build": "tsc -p source -d", | ||
"prepublish": "yarn run build", | ||
"debugtest": "yarn run build && ./node_modules/mocha/bin/mocha --debug-brk", | ||
"test": "yarn run build && ./node_modules/mocha/bin/mocha" | ||
}, | ||
"keywords": [ | ||
"es6", | ||
"typescript", | ||
@@ -23,3 +22,4 @@ "validation" | ||
"dependencies": { | ||
"moment": "^2.15.1", | ||
"moment": "^2.18.1", | ||
"tslib": "^1.6.0", | ||
"validate.js": "^0.11.1" | ||
@@ -29,7 +29,7 @@ }, | ||
"@types/es6-promise": "^0.0.32", | ||
"@types/node": "^6.0.41", | ||
"es6-promise": "^4.0.5", | ||
"@types/node": "^7.0.11", | ||
"es6-promise": "^4.1.0", | ||
"rokot-test": "^0.2.5", | ||
"typescript": "~2.2.0", | ||
"typescript-formatter": "4.1.2" | ||
"typescript": "~2.2.1", | ||
"typescript-formatter": "5.1.2" | ||
}, | ||
@@ -36,0 +36,0 @@ "homepage": "https://github.com/Rocketmakers/rokot-validate", |
Sorry, the diff of this file is not supported yet
69508
3
1049
+ Addedtslib@^1.6.0
+ Addedtslib@1.14.1(transitive)
Updatedmoment@^2.18.1