A plain JavaScript validator for AT Protocol lexicon schemas
1// Test inputs for string schema validation
2
3export const stringSchemaInputs = [
4 {
5 name: 'string-valid-basic',
6 lexicon: {
7 lexicon: 1,
8 id: 'test.string.basic',
9 defs: {
10 main: {
11 type: 'string',
12 minLength: 1,
13 maxLength: 100,
14 },
15 },
16 },
17 },
18 {
19 name: 'string-valid-with-format',
20 lexicon: {
21 lexicon: 1,
22 id: 'test.string.format',
23 defs: {
24 main: {
25 type: 'string',
26 format: 'uri',
27 },
28 },
29 },
30 },
31 {
32 name: 'string-valid-with-enum',
33 lexicon: {
34 lexicon: 1,
35 id: 'test.string.enum',
36 defs: {
37 main: {
38 type: 'string',
39 enum: ['red', 'green', 'blue'],
40 },
41 },
42 },
43 },
44 {
45 name: 'string-invalid-length-constraints',
46 lexicon: {
47 lexicon: 1,
48 id: 'test.string.badlength',
49 defs: {
50 main: {
51 type: 'string',
52 minLength: 100,
53 maxLength: 10,
54 },
55 },
56 },
57 },
58 {
59 name: 'string-invalid-negative-minLength',
60 lexicon: {
61 lexicon: 1,
62 id: 'test.string.negmin',
63 defs: {
64 main: {
65 type: 'string',
66 minLength: -1,
67 },
68 },
69 },
70 },
71 {
72 name: 'string-invalid-negative-maxLength',
73 lexicon: {
74 lexicon: 1,
75 id: 'test.string.negmax',
76 defs: {
77 main: {
78 type: 'string',
79 maxLength: -5,
80 },
81 },
82 },
83 },
84 {
85 name: 'string-invalid-negative-minGraphemes',
86 lexicon: {
87 lexicon: 1,
88 id: 'test.string.negmingraph',
89 defs: {
90 main: {
91 type: 'string',
92 minGraphemes: -10,
93 },
94 },
95 },
96 },
97 {
98 name: 'string-invalid-negative-maxGraphemes',
99 lexicon: {
100 lexicon: 1,
101 id: 'test.string.negmaxgraph',
102 defs: {
103 main: {
104 type: 'string',
105 maxGraphemes: -3,
106 },
107 },
108 },
109 },
110 {
111 name: 'string-valid-with-const',
112 lexicon: {
113 lexicon: 1,
114 id: 'test.string.const',
115 defs: {
116 main: {
117 type: 'string',
118 const: 'fixed-value',
119 },
120 },
121 },
122 },
123 {
124 name: 'string-valid-with-default',
125 lexicon: {
126 lexicon: 1,
127 id: 'test.string.default',
128 defs: {
129 main: {
130 type: 'string',
131 default: 'default-value',
132 },
133 },
134 },
135 },
136 {
137 name: 'string-valid-with-graphemes',
138 lexicon: {
139 lexicon: 1,
140 id: 'test.string.graphemes',
141 defs: {
142 main: {
143 type: 'string',
144 minGraphemes: 1,
145 maxGraphemes: 100,
146 },
147 },
148 },
149 },
150 {
151 name: 'string-valid-no-constraints',
152 lexicon: {
153 lexicon: 1,
154 id: 'test.string.noconstraints',
155 defs: {
156 main: {
157 type: 'string',
158 },
159 },
160 },
161 },
162];