Description
# pyKwalify YAML/JSON validation library This framework is a port with a lot of added functionality of the Java version of the framework kwalify that can be found at http://www.kuwata-lab.com/kwalify/ The original source code can be found at http://sourceforge.net/projects/kwalify/files/kwalify-java/0.5.1/ The source code of the latest release that has been used can be found at https://github.com/sunaku/kwalify. Please note that source code is not the original authors code but a fork/upload of the last release available in Ruby. The schema this library is based on and extended from: http://www.kuwata-lab.com/kwalify/ruby/users-guide.01.html#schema # Usage Create a data file. `Json` and `Yaml` formats are both supported. ```yaml - foo - bar ``` Create a schema file with validation rules. ```yaml type: seq sequence: - type: str ``` Run validation from cli. ```bash pykwalify -d data.yaml -s schema.yaml ``` ## Examples The documentation describes in detail how each keyword and type works and what is possible in each case. But there is a lot of real world examples that can be found in the test data/files. It shows a lot of examples of how all keywords and types work in practice and in combination with each other. The files can be found here and show both schema/data combinations that will work and that will fail. - `tests/files/success/` - `tests/files/fail/` - `tests/files/partial_schemas/` # YAML parser `ruamel.yaml` is the default YAMl parser installed with pykwalify. Ruamel.yaml is more supported in the yaml 1.2 spec and is more actively developed. Depending on how both libraries are developed, this can change in the future in any major update. ## UTF-8 and data encoding If you have problems with unicode values not working properly when running pykwalify on Python 3.6x then try to add this environment variable to your execution: ``` PYTHONIOENCODING=UTF-8 pykwalify ... ``` and it might help to force UTF-8 encoding on all string objects. If this does not work please open up an issue with your schema and data that can be used to track down the problem in the source code. # Project details | | | |---|---| | python support | 3.6, 3.7, 3.8, 3.9 | | Source | https://github.com/Grokzen/pykwalify | | Docs (Latest release) | http://pykwalify.readthedocs.io/en/master/ | | Docs (Unstable branch) | http://pykwalify.readthedocs.io/en/unstable/ | | Gitter (Free Chat) | [](https://gitter.im/Grokzen/pykwalify?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | | Changelog | https://github.com/Grokzen/pykwalify/blob/unstable/docs/release-notes.rst | | Upgrade instructions | https://github.com/Grokzen/pykwalify/blob/unstable/docs/upgrade-instructions.rst | | Issues | https://github.com/Grokzen/pykwalify/issues | | Travis (master) | [](https://travis-ci.org/Grokzen/pykwalify) https://travis-ci.org/Grokzen/pykwalify | | Travis (unstable) | [](https://travis-ci.org/Grokzen/pykwalify) https://travis-ci.org/Grokzen/pykwalify | | Test coverage | [](https://coveralls.io/r/Grokzen/pykwalify) https://coveralls.io/github/Grokzen/pykwalify | | pypi | https://pypi.python.org/pypi/pykwalify/ | | Open Hub | https://www.openhub.net/p/pykwalify | | License | `MIT` https://github.com/Grokzen/pykwalify/blob/unstable/docs/license.rst | | Copyright | `Copyright (c) 2013-2017 Johan Andersson` | | git repo | `git clone git@github.com:Grokzen/pykwalify.git` | | install stable | `pip install pykwalify` | | install dev | `$ git clone git@github.com:Grokzen/pykwalify.git pykwalify`<br>`$ cd ./pykwalify`<br>`$ virtualenv .venv`<br>`$ source .venv/bin/activate`<br>`$ pip install -r dev-requirements.txt`<br>`$ pip install -e .` | | required dependencies | `docopt >= 0.6.2`<br> `python-dateutil >= 2.4.2` | | supported yml parsers | `ruamel.yaml >= 0.11.0` |
Release History
| Version | Changes | Urgency | Date |
|---|---|---|---|
| 1.8.0 | Imported from PyPI (1.8.0) | Low | 4/21/2026 |
| 1.7.0 | **IMPORTANT** LICENSE UPDATE **IMPORTANT** - In this release there was a line removed from the license file. It was modified in the following commit (cc4e31b39ff4cce2dfbc662baa6469470dd3c033 Wed Oct 3 16:20:59 2018 +0200) and will be the main reason for the 1.7.0 release. All commits and tags and releases (1.6.1 and all releases before it) prior to this commit will use the old license that includes the change done in the above mentioned commit. Only release 1.7.0 and commits past | Low | 10/3/2018 |
| 1.6.1 | New keywords: - Added support for keyword *nullable*. It is now possible to allow for a key not to be empty, when *required* keyword is not used. - Added support for keyword *class*. It will not cause any validation errors, but serves to make kwalify schemas compatible that uses that keywork. Bug fixes: - Improved compatibility with unicodes to validate as strings. Changed behaviour: - Propergate json and yaml loading errors when used from the cli to the user for easier debugging | Low | 3/13/2018 |
| 1.6.0 | 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 c | Low | 1/22/2017 |
| 1.5.2 | - Convert all documentation to readthedocs - True/False is no longer considered valid integer - python3 'bytes' objects is now a valid strings and text type - The regular PyYaml support is now deprecated in favor of ruamel.yaml, see the following link for more details about PyYaml being deprecated https://bitbucket.org/xi/pyyaml/issues/59/has-this-project-been-abandoned PyYaml will still be possible to use in the next major release version (1.6.0) but removed in release (1.7.0) and forward. | Low | 11/12/2016 |
| 1.5.1 | - Improvements to documentation (scottclowe). - Improved code linting by reworking private variables in Rule class to now be properties and updated all code that used the old way. - Improved code linting by reworking all Log messages to render according to pep standard. (By using %s and passing in variables as positional arguments) - Fix bug when validating sequence and value should only be unicode escaped when a string - Improve validation of timestamps. - Improve float validation to now ac | Low | 3/6/2016 |
| 1.5.0 | - float / number type now support range restrictions - ranges on non number types (e.g. seq, string) now need to be non negative. - Fixed encoding bug triggered when both regex matching-rule 'any' and 'all' found keyword that failed regex match. Added failure unit tests to cover regex matching-rule 'any' and 'all' during failed regex match. Updated allowed rule list to include matching-rule 'all'. - Changed _validate_mappings method from using re.match to re.search. This fixes bug related | Low | 9/30/2015 |
| 1.4.1 | - Added tests to sdist to enable downstream packaging to run tests. No code changes in this release. | Low | 8/31/2015 |
| 1.4.0 | - Dropped support for python 3.2 becuase of unicode literals do not exists in python 3.2. - Fixed logging & raised exceptions when using unicode characters inside schemas/data/filenames. - Reworked all RuleError exceptions to now have better exception messages. - RuleError exceptions now have a unique 'error_key' that can make it easier to identify what error it is. - Paths for RuleErrors have been moved inside the exception as a variable. - Rewrote all SchemaConflict exceptions to be more human | Low | 8/4/2015 |
| 1.3.0 | - Rewrote most of the error messages to be more human readable. See `docs/Upgrade Instructions.md` for more details. - It is now possible to use the exceptions that was raised for each validation error. It can be found in the variable `c.validation_errors_exceptions`. They contain more detailed information about the error. | Low | 7/13/2015 |
| 1.2.0 | - This feature is **NEW** and **EXPERIMENTAL**. Implemented support for multiple values inside in a sequence. This will allow the defenition of different types that one sequence can contain. You can either require each value in the sequence to be valid against one to all of the different possibilities. Tests show that it still maintains backward compatibility with all old schemas but it can't be guarantee. If you find a regression in this release please file a bug report so it can be f | Low | 5/19/2015 |
| 1.1.0 | - Rework cli string that docopt uses. Removed redundant flags that docopt provides [--version & --help] - Add support for timestamp validation - Add new runtime dependency 'python-dateutil' that is used to validate timestamps - Change how 'any' keyword is implemented to now accept anything and not just the implemented types. (See Upgrade Instructions document for migration details) | Low | 4/4/2015 |
| 1.0.1 | Switched back to semantic version numbering for this lib. See _README.md_ section _Important notes on version schema changes_ on how to fix any issues with this change. | Low | 3/8/2015 |
| 15.01 | - Fixed a bug in unique validation for mapping keys [See: PR-12](Gonditeniz) | Low | 1/17/2015 |
| 14.12 | - Fixed broken regex matching on map keys. - Source files with file ending `.yml` can now be loaded - Added aliases to some directives to make it easier/faster to write - `sequence` --> `seq` - `mapping` --> `map` - `required` --> `req` - `regex` --> `re` - Reworked all testing files to reduce number of files | Low | 12/24/2014 |
| 14.08 | - First version to be uploaded to pypi - Keyword 'range' can now be applied to map & seq types. - Added many more test files. - Keyword 'length' was removed because 'range' can handle all cases now. - Keyword 'range' now correctly checks the internal keys to be integers - Major update to testing and increased coverage. | Low | 8/24/2014 |
| 14.06.1 | - New feature "partial schema". Define a small schema with a ID that can be reused at other places in the schema. See readme for details. - New directive "include" that is used to include a partial schema at the specefied location. - Cli and Core() now can handle multiple schema files. - Directive "pattern" can no longer be used with map to validate all keys against that regex. Use "regex;" inside "mapping:" - 'none' can now be used as a type - Many more tests added | Low | 6/23/2014 |
| 14.06 | - New version scheme [YY.MM(.Minor-Release)] - Added TravisCI support - Update runtime dependency docopt to 0.6.1 - Update runtime dependency pyyaml to 3.11 - Huge refactoring of logging and how it works. Logging config files is now removed and everything is alot simpler - Cleanup some checks that docopt now handles - New keyword "regex;<regex-pattern>" that can be used as a key in map to give more flexibility when validating map keys - New keyword "matching-rule" that can be used to control how | Low | 6/7/2014 |
| 0.1.2 | - Added new and experimental validation rule allowempty. (See README for more info) - Added TODO tracking file. - Reworked the CLI to now use docopt and removede argparse. - Implemented more typechecks, float, number, text, any - Now suports python 3.3.x - No longer support any python 2.x.y version - Enabled pattern for map rule. It enables the validation of all keys in that map. (See README for more info) - Alot more test files and now tests source_data and schema_data input arguments to core.p | Low | 2/9/2014 |
| v0.1.0 | - Initial stable release of pyKwalify. - All functions is not currently implemented but the cli/lib can be used but probably with some bugs. - This should be considered a Alpha release used for bug and stable testing and to be based on further new feature requests for the next version. - Implemented most validation rules from the original Java version of kwalify. Some is currently not implemented and can be found via [NYI] tag in output, doc & code. - Installable via pip (Not the official online | Low | 2/9/2014 |
| v0.1.1 | - Reworked the structure of the project to be more clean and easy to find stuff. - lib/ folder is now removed and all contents is placed in the root of the project - All scripts is now moved to its own folder scripts/ (To use the script during dev the path to the root of the project must be in your python path somehow, recomended is to create a virtualenv and export the correct path when it activates) - New make target 'cleanegg' - Fixed path bugs in Makefile - Fixed path bugs in Manifest | Low | 2/9/2014 |
