required attribute ignored when including partial schemas.
See original GitHub issueI expected the following two schemas to behave the same. Both should require A
be defined in the schema. In actuality, the partial schema seems to ignore the required
attribute.
Data
# A: "required" but omitted
B: hello
Full Schema
mapping:
A:
required: True
type: map
mapping:
D:
required: True
type: str
E:
type: str
B:
type: str
required: True
Output (Error Expected)
$ pykwalify -d data.yml -s schema.yml
ERROR - validation.invalid
ERROR - --- All found errors ---
ERROR - [u"Cannot find required key 'A'. Path: ''"]
Traceback (most recent call last):
File "/usr/local/bin/pykwalify", line 11, in <module>
sys.exit(cli_entrypoint())
File "/usr/local/lib/python2.7/dist-packages/pykwalify/cli.py", line 84, in cli_entrypoint
run(parse_cli())
File "/usr/local/lib/python2.7/dist-packages/pykwalify/cli.py", line 71, in run
c.validate()
File "/usr/local/lib/python2.7/dist-packages/pykwalify/core.py", line 159, in validate
error_msg=u'.\n - '.join(self.validation_errors)))
pykwalify.errors.SchemaError: <SchemaError: error code 2: Schema validation failed:
- Cannot find required key 'A'. Path: ''.: Path: '/'>
Partial Schema Included
mapping:
A:
required: True
include: C
B:
type: str
required: True
schema;C:
type: map
mapping:
D:
required: True
type: str
E:
type: str
Output (Error Expected)
$ pykwalify -d data.yml -s partial.yml
INFO - validation.valid
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
Ignoring "required" in Joi validation? - Stack Overflow
For a create operation, I want to enforce the "required" validation on fields. However, for an update operation, a partial data object may...
Read more >RequiredAttribute Class (System.ComponentModel ...
The RequiredAttribute attribute specifies that when a field on a form is validated, the field must contain a value. A validation exception is...
Read more >Support for XML attributes - IBM
XML schemas can specify attributes that are allowed or required in XML. The CICS assistant utilities DFHWS2LS and DFHSC2LS ignore XML attributes by...
Read more >W3C XML Schema Definition Language (XSD) 1.1 Part 1
Note: Although the blockDefault [attribute] of <schema> may include values other than restriction or extension, those values are ignored in ...
Read more >Quickstart — marshmallow 3.19.0 documentation
Create a schema by defining a class with variables mapping attribute names to Field ... you may only want to skip required validation...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@bernardpletikosa No update on this issue. It might take much more time to implement a fix for this becuase the problem is kinda deep down in how the partial schemas works and it might require much more work to sort this problem out.
Closed as fixed.