Comparing version 2.2.3 to 2.2.4
@@ -1,3 +0,3 @@ | ||
import { Rule } from '../rule/Rule'; | ||
import { Validation } from '../types/Validation'; | ||
import { Rule } from '../rule'; | ||
import { Validation } from '../types'; | ||
export interface FieldOptions { | ||
@@ -4,0 +4,0 @@ rule?: Rule<any>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const Rule_1 = require("../rule/Rule"); | ||
const rule_1 = require("../rule"); | ||
exports.defaultFieldOptions = { | ||
rule: new Rule_1.Rule(), | ||
rule: new rule_1.Rule(), | ||
useFieldName: false, | ||
@@ -7,0 +7,0 @@ }; |
@@ -6,3 +6,3 @@ "use strict"; | ||
const __1 = require(".."); | ||
const StringRule_1 = require("../rule/StringRule"); | ||
const rule_1 = require("../rule"); | ||
const field_1 = require("../test_helpers/field"); | ||
@@ -34,6 +34,13 @@ const utils_1 = require("../utils"); | ||
field.addRule(field_1.extractRule(r)); | ||
chai_1.expect(r.rule).to.an.instanceOf(StringRule_1.StringRule); | ||
chai_1.expect(r.rule).to.an.instanceOf(rule_1.StringRule); | ||
}); | ||
it('should not fail if undefined', () => { | ||
const emptyValue = undefined; | ||
const field = new StringField_1.StringField() | ||
.addRule((r) => r.maxLength(10)); | ||
const validation = field.test(emptyValue); | ||
chai_1.expect(__1.isSuccess(validation)).to.be.true; | ||
}); | ||
}); | ||
}); | ||
//# sourceMappingURL=StringField.spec.js.map |
@@ -10,3 +10,3 @@ "use strict"; | ||
minLength(min) { | ||
this.addInternalTestFunction((str) => str.length >= min, { | ||
this.addInternalTestFunction((str) => str && str.length >= min, { | ||
title: 'too short', | ||
@@ -18,3 +18,3 @@ description: `must be at least ${min} characters long`, | ||
maxLength(max) { | ||
this.addInternalTestFunction((str) => str.length <= max, { | ||
this.addInternalTestFunction((str) => !str || str.length <= max, { | ||
title: 'too long', | ||
@@ -21,0 +21,0 @@ description: `must not be longer than ${max} characters long`, |
@@ -80,4 +80,11 @@ "use strict"; | ||
}); | ||
it('should not fail empty or missing fields', () => { | ||
const schema = new Schema_1.Schema() | ||
.addField('name', (f) => f | ||
.string() | ||
.addRule((r) => r.maxLength(5))); | ||
schema.test({}); | ||
}); | ||
}); | ||
}); | ||
//# sourceMappingURL=Schema.spec.js.map |
@@ -104,4 +104,6 @@ import { expect } from 'chai'; | ||
); | ||
schema.test({}); | ||
}); | ||
}); | ||
}); |
{ | ||
"name": "mev", | ||
"version": "2.2.3", | ||
"version": "2.2.4", | ||
"description": "Another validator..", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
299912
3437