view tests/schemata/test1.schema.yml @ 53:603ad790063a default tip

===== Added signature for changeset 1d6cad03274c
author Franz Glasner <fzglas.hg@dom66.de>
date Thu, 03 Aug 2023 09:26:47 +0200
parents 271ec3abdfa3
children
line wrap: on
line source

# -*- coding: utf-8; mode: yaml; indent-tabs-mode: nil; -*-
#
# This is an sample schema definition file with most features
#
%YAML 1.1
---

$type: dict
keys:
  string-value:
    $type: string
    min-length: 1
    max-length: 255
    pattern:
      any-of:
        - &NAMERE !!python/object/apply:re.compile ['\A[A-Za-z_][A-Za-z0-9_]*\Z']
        - &CALLABLE !!python/name:test_schema._test_generic_validator_for_yaml

  binary-value:
    $type: binary
    min-length: 20
    max-length: 256
    value: *CALLABLE

  int-value:
    $type: int
    min-value: 0
    max-value: 100
    value: *CALLABLE

  float-value:
    $type: float
    min-value: 0.0
    max-value: 50.0
    value: *CALLABLE

  numeric-value:
    $type: number
    min-value: 0
    max-value: 1000
    value: *CALLABLE

  scalar-value:
    $type: scalar

  bool-value:
    $type: bool
    value: *CALLABLE

  timestamp-value:
    $type: timestamp
    value: *CALLABLE

  null-value:
    $type: null

  empty-value:
    $type: empty

  any-value:
    $type: accept

  not-any-value-allowed:
    $type: deny

  custom-value:
    $type: *CALLABLE

  dict-value:
    $type: dict
    keys:
      key1:
        $type: accept
      0:
        $type: accept
      1:
        $type: accept
    key-names:
      one-of:
        - $type: string
        - $type: integer
          min-value: 0
    additional-keys:
      $type: accept         # equivalent to the simpler: additional-keys: true
    required:
      - key1
      - 0

  list-value:
    $type: list
    min-length: 1
    max-length: 10
    items:
      any-of:
        - $type: scalar
        - $type: *CALLABLE

  record-value:
    $type: record
    items:
      - $type: string
      - $type: number
    min-length: 2
    max-length: 2
    additional-items: false

  combinator-one-of:
    one-of:
      - $type: int
      - $type: float
      - $type: null

  combinator-all-of:
    all-of:
      - &NAME 
        $type:      string
        max-length: 255
        pattern: *NAMERE
      - $type: *CALLABLE

  combinator-any-of:
    any-of:
      - *NAME
      - $type: *CALLABLE
      - null

additional-keys: false
required: []