A plain JavaScript validator for AT Protocol lexicon schemas
1// Test inputs for object data validation
2
3export const objectDataInputs = [
4 {
5 name: 'object-data-valid-basic',
6 lexicons: [
7 {
8 lexicon: 1,
9 id: 'test.object.data',
10 defs: {
11 main: {
12 type: 'record',
13 key: 'tid',
14 record: {
15 type: 'object',
16 properties: {
17 title: { type: 'string' },
18 count: { type: 'integer' },
19 },
20 required: ['title'],
21 },
22 },
23 },
24 },
25 ],
26 collection: 'test.object.data',
27 record: { title: 'Hello', count: 42 },
28 },
29 {
30 name: 'object-data-invalid-missing-required',
31 lexicons: [
32 {
33 lexicon: 1,
34 id: 'test.object.required',
35 defs: {
36 main: {
37 type: 'record',
38 key: 'tid',
39 record: {
40 type: 'object',
41 properties: {
42 title: { type: 'string' },
43 },
44 required: ['title'],
45 },
46 },
47 },
48 },
49 ],
50 collection: 'test.object.required',
51 record: { other: 'value' },
52 },
53 {
54 name: 'object-data-valid-nullable-null',
55 lexicons: [
56 {
57 lexicon: 1,
58 id: 'test.object.nullable',
59 defs: {
60 main: {
61 type: 'record',
62 key: 'tid',
63 record: {
64 type: 'object',
65 properties: {
66 name: { type: 'string' },
67 duration: { type: 'integer' },
68 },
69 nullable: ['duration'],
70 },
71 },
72 },
73 },
74 ],
75 collection: 'test.object.nullable',
76 record: { name: 'test', duration: null },
77 },
78 {
79 name: 'object-data-invalid-non-nullable-null',
80 lexicons: [
81 {
82 lexicon: 1,
83 id: 'test.object.nonnullable',
84 defs: {
85 main: {
86 type: 'record',
87 key: 'tid',
88 record: {
89 type: 'object',
90 properties: {
91 name: { type: 'string' },
92 count: { type: 'integer' },
93 },
94 },
95 },
96 },
97 },
98 ],
99 collection: 'test.object.nonnullable',
100 record: { name: 'test', count: null },
101 },
102];