fastest-validator
fastest-validator copied to clipboard
Show warning on bad schema
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?
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
Yes, strict option is good