summaryrefslogtreecommitdiff
path: root/tests/files/fail/test_type_date.yaml
blob: 5a1b39a94fdfcf437a34a1b76dea7701932fadaf (plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
---
name: fail-type-date-1
desc: basic test for date type with default formats
data: "abc"
schema:
  type: date
errors:
  - "Not a valid date: abc Path: ''"
---
name: fail-type-date-2
desc: Basic test for date type with defined date-formats
data: "31-01-2017"
schema:
  type: date
  format: "%Y-%m-%d"
errors:
  - "Not a valid date: 31-01-2017 format: %Y-%m-%d. Path: ''"
---
name: fail-type-date-3
desc: Basic test for date type with defined date-formats
data:
  - "2017"
  - "31"
schema:
  type: seq
  sequence:
    - type: date
      format:
        - "%d-%m-%Y"
        - "%Y-%m-%d"
errors:
  - "Not a valid date: 2017 format: %Y-%m-%d. Path: '/0'"
  - "Not a valid date: 31 format: %Y-%m-%d. Path: '/1'"
---
name: fail-type-data-4
desc: Test date type as values in a list
data:
  - 'abc-1997'
  - 'abc-1997-07'
  - 'abc-1997-07-16'
  - 'abc-1997-07-16T19:20+01:00'
  - 'abc-1997-07-16T19:20:30+01:00'
  - 'abc-1997-07-16T19:20:30.45+01:00'
schema:
  type: seq
  sequence:
    - type: date
errors:
  - "Not a valid date: abc-1997 Path: '/0'"
  - "Not a valid date: abc-1997-07 Path: '/1'"
  - "Not a valid date: abc-1997-07-16 Path: '/2'"
  - "Not a valid date: abc-1997-07-16T19:20+01:00 Path: '/3'"
  - "Not a valid date: abc-1997-07-16T19:20:30+01:00 Path: '/4'"
  - "Not a valid date: abc-1997-07-16T19:20:30.45+01:00 Path: '/5'"
---
name: fail-type-date-5
desc: Test that wrong value types do not validate
data:
  - 123
  - True
schema:
  type: seq
  sequence:
    - type: date
errors:
  - "Value '123' is not of type 'date'. Path: '/0'"
  - "Value 'True' is not of type 'date'. Path: '/1'"
---
name: fail-type-date-6
desc: Test that wrong value types in map do not validate
data:
  foo: 123
  bar: True
schema:
  type: map
  mapping:
    foo:
      type: date
    bar:
      type: date
errors:
  - "Value '123' is not of type 'date'. Path: '/foo'"
  - "Value 'True' is not of type 'date'. Path: '/bar'"