Skip to content

pattern rule not working with all scalar types #177

@rpieterick

Description

@rpieterick

Environment

  • Python version: 3.6.9
  • PyKwalify version: 1.7.0

Documentation states the pattern rule works for all scalar types.
It appears that with the commit for issue #47, the pattern rule only works for string values.

Steps to Reproduce

  1. pykwalify -s schema.yaml -d data.yaml

Schema

type: map
mapping:
  "=":
    type: scalar
    pattern: .*

Data

boolean: true
number: 1
string1: truE
string2: 127.0.0.1

Expected Behavior

Validation passes.

Observed Behavior

 ERROR - validation.invalid
 ERROR -  --- All found errors ---
 ERROR - [u"Value 'True' does not match pattern '.*'. Path: '/boolean'", u"Value '1' does not match pattern '.*'. Path: '/number'"]
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 95, in cli_entrypoint
    run(parse_cli())
  File "/usr/local/lib/python2.7/dist-packages/pykwalify/cli.py", line 82, in run
    c.validate()
  File "/usr/local/lib/python2.7/dist-packages/pykwalify/core.py", line 167, in validate
    error_msg=u'.\n - '.join(self.validation_errors)))
pykwalify.errors.SchemaError: <SchemaError: error code 2: Schema validation failed:
 - Value 'True' does not match pattern '.*'. Path: '/boolean'.
 - Value '1' does not match pattern '.*'. Path: '/number'.: Path: '/'>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions