Socket
Socket
Sign inDemoInstall

rokot-validate

Package Overview
Dependencies
3
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.5.4 to 0.6.0

2

lib/constraintBuilder.d.ts

@@ -17,3 +17,3 @@ import { NumericalityConstraint, Constraints, ClientConstraintSpec, ClientConstraints, ArrayConstraint, ConstraintOrFactory, MustConstraintFunctionReturnType, MustConstraintFunction, IValidatorSpec } from "./validate.js";

export declare class ConstraintBuilder {
array<T>(arrayConstraint?: ConstraintOrFactory<ArrayConstraint>, extend?: Constraints): Constraints;
array<T>(arrayConstraint?: Constraints | ConstraintOrFactory<ArrayConstraint>, extend?: Constraints): Constraints;
arrayMandatory<T>(arrayConstraint?: ConstraintOrFactory<ArrayConstraint>, extend?: Constraints): Constraints;

@@ -20,0 +20,0 @@ arrayValidator<T>(itemValidator: IValidatorSpec<T>, extend?: Constraints): Constraints;

@@ -170,6 +170,6 @@ "use strict";

if (validateJsWithCustomValidators_1.validate.isEmpty(value)) {
return [2 /*return*/, true];
return [2, true];
}
if (!validateJsWithCustomValidators_1.validate.isArray(value)) {
return [2 /*return*/, validator(value)];
return [2, validator(value)];
}

@@ -179,9 +179,9 @@ i = 0;

case 1:
if (!(i < value.length)) return [3 /*break*/, 6];
if (!(i < value.length)) return [3, 6];
validated = validator(value[i]);
if (!validateJsWithCustomValidators_1.isPromise(validated)) return [3 /*break*/, 3];
return [4 /*yield*/, validated];
if (!validateJsWithCustomValidators_1.isPromise(validated)) return [3, 3];
return [4, validated];
case 2:
_a = _b.sent();
return [3 /*break*/, 4];
return [3, 4];
case 3:

@@ -193,3 +193,3 @@ _a = validated;

if (result === false || validateJsWithCustomValidators_1.validate.isString(result) || validateJsWithCustomValidators_1.validate.isArray(result)) {
return [2 /*return*/, result];
return [2, result];
}

@@ -199,4 +199,4 @@ _b.label = 5;

i++;
return [3 /*break*/, 1];
case 6: return [2 /*return*/];
return [3, 1];
case 6: return [2];
}

@@ -203,0 +203,0 @@ });

@@ -75,12 +75,12 @@ "use strict";

}
if (!validate.isArray(validator)) return [3 /*break*/, 5];
if (!validate.isArray(validator)) return [3, 5];
i = 0;
_a.label = 1;
case 1:
if (!(i < validator.length)) return [3 /*break*/, 4];
return [4 /*yield*/, tryValidate(validator[i], value, attributes)];
if (!(i < validator.length)) return [3, 4];
return [4, tryValidate(validator[i], value, attributes)];
case 2:
result = _a.sent();
if (result) {
return [2 /*return*/, result];
return [2, result];
}

@@ -90,7 +90,7 @@ _a.label = 3;

i++;
return [3 /*break*/, 1];
case 4: return [3 /*break*/, 7];
case 5: return [4 /*yield*/, tryValidate(validator, value, attributes)];
case 6: return [2 /*return*/, _a.sent()];
case 7: return [2 /*return*/];
return [3, 1];
case 4: return [3, 7];
case 5: return [4, tryValidate(validator, value, attributes)];
case 6: return [2, _a.sent()];
case 7: return [2];
}

@@ -106,7 +106,7 @@ });

aa = validator.func(value, attributes);
if (!isPromise(aa)) return [3 /*break*/, 2];
return [4 /*yield*/, aa];
if (!isPromise(aa)) return [3, 2];
return [4, aa];
case 1:
_a = _b.sent();
return [3 /*break*/, 3];
return [3, 3];
case 2:

@@ -118,8 +118,8 @@ _a = aa;

if (validate.isString(valid) || validate.isArray(valid)) {
return [2 /*return*/, valid];
return [2, valid];
}
if (valid === false) {
return [2 /*return*/, validator.message ? validate.format(validator.message, attributes) : "condition not met"];
return [2, validator.message ? validate.format(validator.message, attributes) : "condition not met"];
}
return [2 /*return*/];
return [2];
}

@@ -126,0 +126,0 @@ });

@@ -126,3 +126,3 @@ "use strict";

}
return [4 /*yield*/, this.recursivelyValidate(new VisitData(), instance, validation)];
return [4, this.recursivelyValidate(new VisitData(), instance, validation)];
case 1:

@@ -135,3 +135,3 @@ result = _a.sent();

ValidationResultHelper.resolveRefs(result);
return [2 /*return*/, Cleaner.recursivelyClean(result, new VisitData())];
return [2, Cleaner.recursivelyClean(result, new VisitData())];
}

@@ -147,8 +147,8 @@ });

case 0:
if (!this.hasContext(spec)) return [3 /*break*/, 2];
return [4 /*yield*/, spec.getContext(instance, !key)];
if (!this.hasContext(spec)) return [3, 2];
return [4, spec.getContext(instance, !key)];
case 1:
ctx = _a.sent();
return [2 /*return*/, this.makeValidationContext(spec, instance, key, parentKey, ctx)];
case 2: return [2 /*return*/, this.makeValidationContext(spec, instance, key, parentKey)];
return [2, this.makeValidationContext(spec, instance, key, parentKey, ctx)];
case 2: return [2, this.makeValidationContext(spec, instance, key, parentKey)];
}

@@ -197,11 +197,11 @@ });

if (stored) {
return [2 /*return*/, ValidationResultHelper.makeRef(key, parentKey, stored)];
return [2, ValidationResultHelper.makeRef(key, parentKey, stored)];
}
visitData.store(instance, id);
}
return [4 /*yield*/, this.getValidationContext(spec, instance, key, parentKey)];
return [4, this.getValidationContext(spec, instance, key, parentKey)];
case 1:
context = _a.sent();
return [4 /*yield*/, this.validateContext(visitData, id, context)];
case 2: return [2 /*return*/, _a.sent()];
return [4, this.validateContext(visitData, id, context)];
case 2: return [2, _a.sent()];
}

@@ -216,3 +216,3 @@ });

switch (_a.label) {
case 0: return [4 /*yield*/, this.getValidationErrors(validationContext)];
case 0: return [4, this.getValidationErrors(validationContext)];
case 1:

@@ -222,9 +222,9 @@ errors = _a.sent();

if (!validationContext.validators || !validationContext.instance) {
return [2 /*return*/, validationResult];
return [2, validationResult];
}
return [4 /*yield*/, Validation.getChildValidationResults(visitData, validationContext)];
return [4, Validation.getChildValidationResults(visitData, validationContext)];
case 2:
results = _a.sent();
validationResult.children = results;
return [2 /*return*/, validationResult];
return [2, validationResult];
}

@@ -245,16 +245,16 @@ });

case 1:
if (!(i < keys.length)) return [3 /*break*/, 9];
if (!(i < keys.length)) return [3, 9];
key = keys[i];
value = validationContext.instance[key];
if (!validateJsWithCustomValidators_1.validate.isDefined(value)) {
return [3 /*break*/, 8];
return [3, 8];
}
spec = validationContext.validators[key];
if (!validateJsWithCustomValidators_1.validate.isArray(value)) return [3 /*break*/, 6];
if (!validateJsWithCustomValidators_1.validate.isArray(value)) return [3, 6];
idx = 0;
_a.label = 2;
case 2:
if (!(idx < value.length)) return [3 /*break*/, 5];
if (!(idx < value.length)) return [3, 5];
arrayKey = key + "." + idx;
return [4 /*yield*/, this.recursivelyValidate(visitData, value[idx], spec, arrayKey, this.makeKey(arrayKey, validationContext.parentKey))];
return [4, this.recursivelyValidate(visitData, value[idx], spec, arrayKey, this.makeKey(arrayKey, validationContext.parentKey))];
case 3:

@@ -268,7 +268,7 @@ ve_1 = _a.sent();

idx++;
return [3 /*break*/, 2];
return [3, 2];
case 5:
;
return [3 /*break*/, 8];
case 6: return [4 /*yield*/, this.recursivelyValidate(visitData, value, spec, key, this.makeKey(key, validationContext.parentKey))];
return [3, 8];
case 6: return [4, this.recursivelyValidate(visitData, value, spec, key, this.makeKey(key, validationContext.parentKey))];
case 7:

@@ -282,4 +282,4 @@ ve = _a.sent();

i++;
return [3 /*break*/, 1];
case 9: return [2 /*return*/, results];
return [3, 1];
case 9: return [2, results];
}

@@ -299,4 +299,4 @@ });

_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, validateJsWithCustomValidators_1.validate.async(validationContext.instance, validationContext.constraints, { format: "detailed" })];
case 1: return [2 /*return*/, _a.sent()];
return [4, validateJsWithCustomValidators_1.validate.async(validationContext.instance, validationContext.constraints, { format: "detailed" })];
case 1: return [2, _a.sent()];
case 2:

@@ -307,3 +307,3 @@ errors_2 = _a.sent();

}
return [2 /*return*/, errors_2.map(function (d) {
return [2, errors_2.map(function (d) {
return {

@@ -315,3 +315,3 @@ message: d.error,

})];
case 3: return [2 /*return*/];
case 3: return [2];
}

@@ -318,0 +318,0 @@ });

{
"name": "rokot-validate",
"version": "0.5.4",
"version": "0.6.0",
"description": "Rocketmakers Rokot Platform - Validation",

@@ -22,12 +22,11 @@ "main": "./lib/index.js",

"moment": "^2.18.1",
"tslib": "^1.6.0",
"tslib": "^1.7.1",
"validate.js": "^0.11.1"
},
"devDependencies": {
"@types/es6-promise": "^0.0.32",
"@types/node": "^7.0.11",
"es6-promise": "^4.1.0",
"rokot-test": "^0.2.5",
"typescript": "~2.2.1",
"typescript-formatter": "5.1.2"
"@types/node": "^8.0.12",
"es6-promise": "^4.1.1",
"rokot-test": "^0.3.0",
"typescript": "~2.4.1",
"typescript-formatter": "5.2.0"
},

@@ -34,0 +33,0 @@ "homepage": "https://github.com/Rocketmakers/rokot-validate",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc