Skip to content

Commit

Permalink
Update options validation spec
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscomorais committed Feb 19, 2020
1 parent 46171d2 commit f94db48
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions spec/options/options_validation.spec.js
Expand Up @@ -26,12 +26,35 @@ describe('validation options', function() {
}});

var validate = ajv.compile({ format: 'identifier' });

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

describe('keywords', function() {
it('should add keywords from options', function() {
var ajv = new Ajv({ keywords: {
string: {
validate: function (schema, data ) {

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

var validate = ajv.compile({ string: 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);
});
});


describe('uniqueItems', function() {
it('should not validate uniqueItems with uniqueItems option == false', function() {
Expand Down

0 comments on commit f94db48

Please sign in to comment.