Checklist
Detailed Description
I'm trying to understand the opinionated nature of the validator library. It seems like it forces some things on to you like:
{
anyOf: [
{ type: 'array', items: { type: 'string' } },
{
type: 'object',
additionalProperties: { enum: [ 'commonjs', 'module' ] }
}
],
default: [ 'cjs', 'mjs', 'js' ]
}
will fail because it is missing a type field, even though the specs don't seem to suggest it's required. Equally if i try to massage an if/then/else into a valid draft-04 from:
"if": {
"properties": {
"country": {
"const": "United States of America"
}
}
},
"then": {
"properties": {
"postal_code": {
"pattern": "[0-9]{5}(-[0-9]{4})?"
}
}
},
"else": {
"properties": {
"postal_code": {
"pattern": "[A-Z][0-9][A-Z] [0-9][A-Z][0-9]"
}
}
}
to
oneOf: [
{
allOf: [
{
"properties": {
"country": {
"const": "United States of America"
}
}
},
"properties": {
"postal_code": {
"pattern": "[0-9]{5}(-[0-9]{4})?"
}
}
]
},
{
allOf: [
{
not: {
"properties": {
"country": {
"const": "United States of America"
}
}
}
},
"properties": {
"postal_code": {
"pattern": "[A-Z][0-9][A-Z] [0-9][A-Z][0-9]"
}
}
]
}
]
it will complain that
"properties": {
"postal_code": {
"pattern": "[0-9]{5}(-[0-9]{4})?"
}
}
needs to be in its own schema components reference.
Other stuff
Checklist
Detailed Description
I'm trying to understand the opinionated nature of the validator library. It seems like it forces some things on to you like:
{ anyOf: [ { type: 'array', items: { type: 'string' } }, { type: 'object', additionalProperties: { enum: [ 'commonjs', 'module' ] } } ], default: [ 'cjs', 'mjs', 'js' ] }will fail because it is missing a
typefield, even though the specs don't seem to suggest it's required. Equally if i try to massage an if/then/else into a valid draft-04 from:to
it will complain that
needs to be in its own schema components reference.
Other stuff