Skip to content

Commit

Permalink
test: update option keywords test
Browse files Browse the repository at this point in the history
  • Loading branch information
epoberezkin committed Feb 22, 2020
1 parent c90c189 commit e5bed30
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions spec/options/options_validation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe('validation options', function() {
var validate = ajv.compile({ format: 'identifier' });

validate('Abc1') .should.equal(true);
validate('foo bar') .should.equal(false);
validate('123') .should.equal(false);
validate(123) .should.equal(true);
});
Expand All @@ -36,22 +37,20 @@ describe('validation options', function() {
describe('keywords', function() {
it('should add keywords from options', function() {
var ajv = new Ajv({ keywords: {
string: {
identifier: {
type: 'string',
validate: function (schema, data ) {

console.log(">>", data);
return /^[a-z_$][a-z0-9_$]*$/i.test(data);
}
}
}});

var validate = ajv.compile({ string: true });
var validate = ajv.compile({ identifier: true });

validate('Abc1') .should.equal(true);
validate('foo bar').should.equal(false);
validate('123').should.equal(false);
validate(123).should.equal(false);
validate(123).should.equal(false);
validate('foo bar') .should.equal(false);
validate('123') .should.equal(false);
validate(123) .should.equal(true);
});
});

Expand Down

0 comments on commit e5bed30

Please sign in to comment.