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

type: dict
keys:
  string-value:
    type: string
    minLength: 1
    maxLength: 255
    pattern:
      anyOf:
        - &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
    minLength: 20
    maxLength: 256
    value: *CALLABLE

  int-value:
    type: int
    minValue: 0
    maxValue: 100
    value: *CALLABLE

  float-value:
    type: float
    minValue: 0.0
    maxValue: 50.0
    value: *CALLABLE

  numeric-value:
    type: number
    minValue: 0
    maxValue: 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
    keyNames:
      oneOf:
        - type: string
        - type: integer
          minValue: 0
    additionalKeys:
      type: accept         # equivalent to the simpler: additionalKeys: true
    required:
      - key1
      - 0

  list-value:
    type: list
    minLength: 1
    maxLength: 10
    items:
      anyOf:
        - type: scalar
        - type: *CALLABLE

  record-value:
    type: record
    items:
      - type: string
      - type: number
    minLength: 2
    maxLength: 2
    additionalItems: false

  combinator-oneOf:
    oneOf:
      - type: int
      - type: float
      - type: null

  combinator-allOf:
    allOf:
      - &NAME 
        type:      string
        maxLength: 255
        pattern: *NAMERE
      - type: *CALLABLE

  combinator-anyOf:
    anyOf:
      - *NAME
      - type: *CALLABLE
      - null

additionalKeys: false
required: []
