File: basics.rst

package info (click to toggle)
pykwalify 1.8.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 912 kB
  • sloc: python: 3,315; makefile: 225
file content (35 lines) | stat: -rw-r--r-- 662 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Basic Usage
===========

Create a data ``json`` or ``yaml`` file.

.. code-block:: yaml

    # Data file (data.yaml)
    - foo
    - bar

Create a schema file with validation rules.

.. code-block:: yaml

    # Schema file (schema.yaml)
    type: seq
    sequence:
      - type: str

Run validation from cli.

.. code-block:: bash

    pykwalify -d data.yaml -s schema.yaml

Or if you want to run the validation from inside your code directly.

.. code-block:: python

    from pykwalify.core import Core
    c = Core(source_file="data.yaml", schema_files=["schema.yaml"])
    c.validate(raise_exception=True)

If validation fails then exception will be raised.