tdegrunt / jsonschema

JSON Schema validation
Other
1.83k stars 263 forks source link

alpha-numeric format not working #336

Open conde2 opened 3 years ago

conde2 commented 3 years ago

Hello I just noticed that the alpha-numeric format is not working, here is an example: I want to add multiple formats thats why I'm using allOf,

I'm using Typescript 4.3 Node 14.15.4

var validator = new Validator();
console.log(validator.validate('Hi2-**,', {
    type: 'string',
    allOf: [
        {
            format: 'alpha-numeric',
        }
    ]

}).valid);

It should log false, but it is returning true

conde2 commented 3 years ago

I just notice that it should be alphanumeric instead of alpha-numeric

I think would be good to update the examples/all.js

https://github.com/tdegrunt/jsonschema/blob/03ca6827027fcc9bf75afa14cf11220bf9e4e67c/examples/all.js#L214

conde2 commented 3 years ago

Another documentation error I found is that

var res = validate(undefined, {type: 'string'}, {required: true});

But my compiler complains, because it is not specified in Options interface

Argument of type '{ required: boolean; }' is not assignable to parameter of type 'Options'.
  Object literal may only specify known properties, and 'required' does not exist in type 'Options'.ts(2345)