A plain JavaScript validator for AT Protocol lexicon schemas
at main 185 lines 3.8 kB view raw
1// Test inputs for query data validation 2 3export const queryDataInputs = [ 4 { 5 name: 'query-data-valid-parameters', 6 lexicons: [ 7 { 8 lexicon: 1, 9 id: 'test.query.data', 10 defs: { 11 main: { 12 type: 'query', 13 parameters: { 14 type: 'params', 15 properties: { 16 limit: { 17 type: 'integer', 18 minimum: 1, 19 maximum: 100, 20 }, 21 cursor: { type: 'string' }, 22 }, 23 }, 24 }, 25 }, 26 }, 27 ], 28 collection: 'test.query.data', 29 record: { 30 limit: 50, 31 cursor: 'abc123', 32 }, 33 }, 34 { 35 name: 'query-data-valid-with-required', 36 lexicons: [ 37 { 38 lexicon: 1, 39 id: 'test.query.required', 40 defs: { 41 main: { 42 type: 'query', 43 parameters: { 44 type: 'params', 45 properties: { 46 repo: { type: 'string' }, 47 }, 48 required: ['repo'], 49 }, 50 }, 51 }, 52 }, 53 ], 54 collection: 'test.query.required', 55 record: { 56 repo: 'did:plc:abc123', 57 }, 58 }, 59 { 60 name: 'query-data-invalid-missing-required', 61 lexicons: [ 62 { 63 lexicon: 1, 64 id: 'test.query.missingreq', 65 defs: { 66 main: { 67 type: 'query', 68 parameters: { 69 type: 'params', 70 properties: { 71 repo: { type: 'string' }, 72 collection: { type: 'string' }, 73 }, 74 required: ['repo'], 75 }, 76 }, 77 }, 78 }, 79 ], 80 collection: 'test.query.missingreq', 81 record: { 82 collection: 'app.bsky.feed.post', 83 }, 84 }, 85 { 86 name: 'query-data-invalid-wrong-type', 87 lexicons: [ 88 { 89 lexicon: 1, 90 id: 'test.query.wrongtype', 91 defs: { 92 main: { 93 type: 'query', 94 parameters: { 95 type: 'params', 96 properties: { 97 limit: { 98 type: 'integer', 99 minimum: 1, 100 }, 101 }, 102 }, 103 }, 104 }, 105 }, 106 ], 107 collection: 'test.query.wrongtype', 108 record: { 109 limit: 'not-a-number', 110 }, 111 }, 112 { 113 name: 'query-data-invalid-constraint-violation', 114 lexicons: [ 115 { 116 lexicon: 1, 117 id: 'test.query.constraint', 118 defs: { 119 main: { 120 type: 'query', 121 parameters: { 122 type: 'params', 123 properties: { 124 limit: { 125 type: 'integer', 126 maximum: 100, 127 }, 128 }, 129 }, 130 }, 131 }, 132 }, 133 ], 134 collection: 'test.query.constraint', 135 record: { 136 limit: 200, 137 }, 138 }, 139 { 140 name: 'query-data-valid-array-parameter', 141 lexicons: [ 142 { 143 lexicon: 1, 144 id: 'test.query.array', 145 defs: { 146 main: { 147 type: 'query', 148 parameters: { 149 type: 'params', 150 properties: { 151 tags: { 152 type: 'array', 153 items: { 154 type: 'string', 155 maxLength: 50, 156 }, 157 }, 158 }, 159 }, 160 }, 161 }, 162 }, 163 ], 164 collection: 'test.query.array', 165 record: { 166 tags: ['tag1', 'tag2'], 167 }, 168 }, 169 { 170 name: 'query-data-valid-no-parameters', 171 lexicons: [ 172 { 173 lexicon: 1, 174 id: 'test.query.noparam', 175 defs: { 176 main: { 177 type: 'query', 178 }, 179 }, 180 }, 181 ], 182 collection: 'test.query.noparam', 183 record: {}, 184 }, 185];