jaywalk
Version:
Runtime type validation
26 lines • 988 B
JavaScript
;
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Promise = require('any-promise');
var rule_1 = require('./rule');
var Transform = (function (_super) {
__extends(Transform, _super);
function Transform(options) {
_super.call(this, options);
this.type = 'Test';
this.name = options.name;
this.transform = options.transform;
this._tests.push(toTransformTest(this.transform));
}
return Transform;
}(rule_1.Rule));
exports.Transform = Transform;
function toTransformTest(transform) {
return function (value, path, context, next) {
return new Promise(function (resolve) { return resolve(transform(value)); }).then(function (res) { return next(res); });
};
}
//# sourceMappingURL=transform.js.map