New keywords:
- Add support for keyword _example_. It does nothing and have no validation done on it.
- Add support for keyword _version_. It does nothing and have no validation done on it.
- Add support for keyword _date_ and added support keyword _format_. This can be used to validate many different types of _datetime_ objects.
- Add support for keyword _length_. It is very similar to _range_ but works primarily string types.
- Add support for keyword _assert_. It works by running the python code _assert <assert-expr>_ and check if any exception is raised.
This feature is considered dangerouns becuase there is only simple logic to prevent escaping out from validation.
Bug fixes:
- Fixed a bug where regexes marked as 'required' in a map were matched as strings, rather than regexes.
- Fixed a bug where the type validation did not work when schema specefied a sequence of map objects. It now outputs a proper `...is not a dict...` error instead.
- Fixed a bug in _unique_ validation when a key that it tried to lookup in the data would not exists.
Now it just ignores that it did not find any value becuase a missing value do not impact validation.
- Fixed a bug with keyword _ident_ when the rule value was verified to be a _boolean_. It now only accepts _boolean_ values as expected.
- Fixed a bug where if _allowempty_ was specefied in a mapping type inside a sequence type then it would not properly validate.
- Fixed a bug where loaded extensions would not allways work in complex & nested objects.
- Fixed a major bug in very nested _seq_ schemas where if the schema expected another _seq_ but the value was something else it would not raise it as a validation error.
This has now been fixed and now raises the proper error.
- Fixed a bug where include directive would not work in all cases when used inside a key in a mapping block.
New features:
- It is now possible to specify a default rule when using a mapping.
The rule will be used whenever no other key could be found.
This is a port of a missing feature from original kwalify implementation.
- Added new helper method _keywords_ to _Rule_ class that can output all active keywords for any _Rule_ object.
This helps when debugging code to be able to easily dump what all active keywords for any _Rule_ object.
- Added new cli flag _--strict-rule-validation_ that will validate that all used keywords in all _Rule_ objects only uses the rules that is supported by each defined type.
If you only use a _Core_ object then set _strict_rule_validation=True_ when creating the _Core_ object instance.
This feature is opt-in in this releaes but will be mandatory in _releases >= 1.7.0_.
- Added new cli flag _--fix-ruby-style-regex_ that will trim slashes from ruby style regex/patterns.
When using this flag the first and last _/_ will be trimmed of the pattern before running validation.
If you only use a _Core_ object then set _fix_ruby_style_regex=True_ when creating the _Core_ object instance.
Default behaviour will still be that you should use python style regex values but this flag can help in some cases when you can't change the schema.
- Added new cli flag _--allow-assertions_ that will enable the otherwise blocked keyword _assert_.
This flag was introduced so that pykwalify would not assert assertions without user controll.
Default behaviour will be to raise a _CoreError_ is assertion is used but not allowed explicitly.
If you only use a _Core_ object then set _allow_assertions=True_ when creating the _Core_ object instance.
Changed behaviour:
- Removed the force of _UTF-8_ encoding when importing pykwalify package. It caused issues with _jypiter notebooks_ on python 2.7.x
Added documentation in Readme regarding the suggested solution to use _PYTHONIOENCODING=UTF-8_ if the default solution do not work.
- Validation do no longer continue to process things like _pattern_, _regex_, _timestamp_, _range_ and other additional checks
if the type check fails. This can cause problems where previous errors will now initially be silenced when the typecheck for
that value fails, but reappear again when the type check is fixed. (sbrunner)
- Catches _TypeError_ when doing regex validation. That happens when the value is not a parsable string type.
- Checking that the value is a valid dict object is now done even if the mapping keyword is not specefied in the schema.
This makes that check more eager and errors can apear that previously was not there.
- Changed the sane default type if that key is not defined to be _str_. Before this, type had to be defined every time and the default type did not work as expected.
This is a major change and can cause validation to either fail or to stop failing depending on the case.
- Changed validation for if a value is required and a value in a list for example is _None_. It now adds a normal validation errors instead of raising a _CoreError_.
- Value for keyword _desc_ now _MUST_ be a string or a _RuleError_ will be raised.
- Value for keyword _example_ now _MUST_ be a string or a _RuleError_ will be raised.
- Value for keyword _name_ now _MUST_ be a string or a _RuleError_ will be raised.
General changes:
- Ported alot of testcases directly from _Kwalify_ test data (_test-validator.yaml -> 30f.yaml & 43s.yaml_) so that this lib can have greater confidence that rules is implemented in the same way as _Kwalify_.
- Refactored _test_core_files_ method to now accept test files with multiple of documents. The method now tries to read all documents from each test file and run each document seperatly.
It now alos reports more detailed about what file and document that fails the test to make it easier to track down problems.
- Major refactoring of test files to now be grouped based on what they are testing instead of a increased counter that do not represent anything.
It will be easier to find out what keywords lack tests and what keywords that have enough tests.