A plain JavaScript validator for AT Protocol lexicon schemas
1// Test inputs for datetime format validation
2
3export const datetimeFormatInputs = [
4 {
5 name: 'datetime-valid-utc',
6 lexicons: [
7 {
8 lexicon: 1,
9 id: 'test.format.datetime',
10 defs: {
11 main: {
12 type: 'record',
13 key: 'tid',
14 record: {
15 type: 'object',
16 properties: {
17 createdAt: { type: 'string', format: 'datetime' },
18 },
19 },
20 },
21 },
22 },
23 ],
24 collection: 'test.format.datetime',
25 record: { createdAt: '2024-01-01T12:00:00Z' },
26 },
27 {
28 name: 'datetime-valid-with-offset',
29 lexicons: [
30 {
31 lexicon: 1,
32 id: 'test.format.datetime',
33 defs: {
34 main: {
35 type: 'record',
36 key: 'tid',
37 record: {
38 type: 'object',
39 properties: {
40 createdAt: { type: 'string', format: 'datetime' },
41 },
42 },
43 },
44 },
45 },
46 ],
47 collection: 'test.format.datetime',
48 record: { createdAt: '2024-01-01T12:00:00+00:00' },
49 },
50 {
51 name: 'datetime-valid-with-milliseconds',
52 lexicons: [
53 {
54 lexicon: 1,
55 id: 'test.format.datetime',
56 defs: {
57 main: {
58 type: 'record',
59 key: 'tid',
60 record: {
61 type: 'object',
62 properties: {
63 createdAt: { type: 'string', format: 'datetime' },
64 },
65 },
66 },
67 },
68 },
69 ],
70 collection: 'test.format.datetime',
71 record: { createdAt: '2024-01-01T12:00:00.123Z' },
72 },
73 {
74 name: 'datetime-invalid-negative-zero-offset',
75 lexicons: [
76 {
77 lexicon: 1,
78 id: 'test.format.datetime',
79 defs: {
80 main: {
81 type: 'record',
82 key: 'tid',
83 record: {
84 type: 'object',
85 properties: {
86 createdAt: { type: 'string', format: 'datetime' },
87 },
88 },
89 },
90 },
91 },
92 ],
93 collection: 'test.format.datetime',
94 record: { createdAt: '2024-01-01T12:00:00-00:00' },
95 },
96 {
97 name: 'datetime-invalid-feb-30',
98 lexicons: [
99 {
100 lexicon: 1,
101 id: 'test.format.datetime',
102 defs: {
103 main: {
104 type: 'record',
105 key: 'tid',
106 record: {
107 type: 'object',
108 properties: {
109 createdAt: { type: 'string', format: 'datetime' },
110 },
111 },
112 },
113 },
114 },
115 ],
116 collection: 'test.format.datetime',
117 record: { createdAt: '2024-02-30T12:00:00Z' },
118 },
119 {
120 name: 'datetime-invalid-empty',
121 lexicons: [
122 {
123 lexicon: 1,
124 id: 'test.format.datetime',
125 defs: {
126 main: {
127 type: 'record',
128 key: 'tid',
129 record: {
130 type: 'object',
131 properties: {
132 createdAt: { type: 'string', format: 'datetime' },
133 },
134 },
135 },
136 },
137 },
138 ],
139 collection: 'test.format.datetime',
140 record: { createdAt: '' },
141 },
142];