A plain JavaScript validator for AT Protocol lexicon schemas
1// Test inputs for bytes data validation
2
3export const bytesDataInputs = [
4 {
5 name: 'bytes-data-valid-basic',
6 lexicons: [
7 {
8 lexicon: 1,
9 id: 'test.bytes.data',
10 defs: {
11 main: {
12 type: 'record',
13 key: 'tid',
14 record: {
15 type: 'object',
16 properties: {
17 data: {
18 type: 'bytes',
19 },
20 },
21 },
22 },
23 },
24 },
25 ],
26 collection: 'test.bytes.data',
27 record: { data: { $bytes: 'MTIz' } }, // "123" in base64
28 },
29 {
30 name: 'bytes-data-valid-with-constraints',
31 lexicons: [
32 {
33 lexicon: 1,
34 id: 'test.bytes.constraints',
35 defs: {
36 main: {
37 type: 'record',
38 key: 'tid',
39 record: {
40 type: 'object',
41 properties: {
42 data: {
43 type: 'bytes',
44 minLength: 10,
45 maxLength: 20,
46 },
47 },
48 },
49 },
50 },
51 },
52 ],
53 collection: 'test.bytes.constraints',
54 record: { data: { $bytes: 'YXNkZmFzZGZhc2RmYXNkZg' } }, // 16 bytes
55 },
56 {
57 name: 'bytes-data-invalid-plain-string',
58 lexicons: [
59 {
60 lexicon: 1,
61 id: 'test.bytes.plainstring',
62 defs: {
63 main: {
64 type: 'record',
65 key: 'tid',
66 record: {
67 type: 'object',
68 properties: {
69 data: {
70 type: 'bytes',
71 },
72 },
73 },
74 },
75 },
76 },
77 ],
78 collection: 'test.bytes.plainstring',
79 record: { data: 'green' },
80 },
81 {
82 name: 'bytes-data-invalid-empty-object',
83 lexicons: [
84 {
85 lexicon: 1,
86 id: 'test.bytes.emptyobj',
87 defs: {
88 main: {
89 type: 'record',
90 key: 'tid',
91 record: {
92 type: 'object',
93 properties: {
94 data: {
95 type: 'bytes',
96 },
97 },
98 },
99 },
100 },
101 },
102 ],
103 collection: 'test.bytes.emptyobj',
104 record: { data: {} },
105 },
106 {
107 name: 'bytes-data-invalid-too-short',
108 lexicons: [
109 {
110 lexicon: 1,
111 id: 'test.bytes.tooshort',
112 defs: {
113 main: {
114 type: 'record',
115 key: 'tid',
116 record: {
117 type: 'object',
118 properties: {
119 data: {
120 type: 'bytes',
121 minLength: 10,
122 },
123 },
124 },
125 },
126 },
127 },
128 ],
129 collection: 'test.bytes.tooshort',
130 record: { data: { $bytes: 'b25l' } }, // "one" = 3 bytes
131 },
132 {
133 name: 'bytes-data-invalid-too-long',
134 lexicons: [
135 {
136 lexicon: 1,
137 id: 'test.bytes.toolong',
138 defs: {
139 main: {
140 type: 'record',
141 key: 'tid',
142 record: {
143 type: 'object',
144 properties: {
145 data: {
146 type: 'bytes',
147 maxLength: 5,
148 },
149 },
150 },
151 },
152 },
153 },
154 ],
155 collection: 'test.bytes.toolong',
156 record: { data: { $bytes: 'YXNkZmFzZGZhc2RmYXNkZg' } }, // 16 bytes
157 },
158];