question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

required attribute ignored when including partial schemas.

See original GitHub issue

I 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:closed
  • Created 7 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Grokzencommented, Dec 21, 2016

@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.

0reactions
Grokzencommented, Jan 22, 2017

Closed as fixed.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found