requiredAttributes cannot be empty
Setting requiredAttributes
to an empty array causes validation error.
Reduced test-case
{
"my-element": {
"inherit": "input",
"requiredAttributes": []
}
}
Expected result
Element metadata for <my-element>
should not have any required attributes.
Actual result
Validator crashed when parsing "/path/to/file"
Caught exception:
{ Error: Element metadata is not valid: /my-element/requiredAttributes: contains should contain a valid item
at new UserError (node_modules\html-validate\build\error\user-error.js:4:1)
at new MetaValidationError (node_modules\html-validate\build\meta\validation-error.js:10:9)
at MetaTable.loadFromObject (node_modules\html-validate\build\meta\table.js:68:19)
at MetaTable.loadFromFile (node_modules\html-validate\build\meta\table.js:85:14)
at Config.getMetaTable (node_modules\html-validate\build\config\config.js:194:27)
at new Parser (node_modules\html-validate\build\parser\parser.js:21:33)
at Engine.instantiateParser (node_modules\html-validate\build\engine\engine.js:132:16)
at Engine.lint (node_modules\html-validate\build\engine\engine.js:28:33)
at HtmlValidate.validateFile (node_modules\html-validate\build\htmlvalidate.js:69:23)
at files.map (node_modules\html-validate\build\cli\html-validate.js:47:33)
obj:
{ 'my-element':
{ inherit: 'input',
flow: true,
void: false,
slots: [Array],
requiredAttributes: [] } },
schema:
{ '$id': 'https://html-validate.org/schemas/metadata.json',
type: 'object',
patternProperties: { '^.*$': [Object] },
definitions:
{ contentCategory: [Object],
expression: [Object],
operation: [Object],
Permitted: [Object],
PermittedAttribute: [Object],
PermittedGroup: [Object],
PermittedOrder: [Object],
RequiredAncestors: [Object],
RequiredContent: [Object] } },
errors:
[ { keyword: 'contains',
dataPath: '/my-error/requiredAttributes',
schemaPath:
'#/patternProperties/%5E.*%24/properties/requiredAttributes/contains',
params: {},
message: 'should contain a valid item' } ] }
Version
-
html-validate
: 2.5.0