fastest-validator icon indicating copy to clipboard operation
fastest-validator copied to clipboard

Show warning on bad schema

Open erfanium opened this issue 5 years ago • 2 comments

If there is a problem with the schema, the validator currently only ignores it, and does not show any message. for example:

const schema = {
   foo: "number|min=1|max=10"
}

Although the shorthand has a problem (used = instead of :) but I didn't get any errors! (This happened to me exactly today) or something like:

const schema = {
   foo: {
      type: "string",
      foo: "bar"
   }
}

FV should show a warning because "foo" is not a valid option for string rule.

@icebob What you think? Is an error better or a warning?

erfanium avatar Oct 05 '20 14:10 erfanium

But FV doesn't know that foo property is not used, because you can use custom check functions where you use it. So if we want to strict the properties, it can be only an extra feature option in the constructor instead of a permanent feature.

icebob avatar Oct 07 '20 08:10 icebob

@icebob Yes, strict option is good

erfanium avatar Oct 07 '20 09:10 erfanium