A plain JavaScript validator for AT Protocol lexicon schemas
at main 212 lines 4.5 kB view raw
1// Test inputs for string data validation 2 3export const stringDataInputs = [ 4 { 5 name: 'string-data-valid-basic', 6 lexicons: [ 7 { 8 lexicon: 1, 9 id: 'test.string.data', 10 defs: { 11 main: { 12 type: 'record', 13 key: 'tid', 14 record: { 15 type: 'object', 16 properties: { 17 text: { 18 type: 'string', 19 minLength: 1, 20 maxLength: 10, 21 }, 22 }, 23 }, 24 }, 25 }, 26 }, 27 ], 28 collection: 'test.string.data', 29 record: { text: 'hello' }, 30 }, 31 { 32 name: 'string-data-invalid-too-short', 33 lexicons: [ 34 { 35 lexicon: 1, 36 id: 'test.string.short', 37 defs: { 38 main: { 39 type: 'record', 40 key: 'tid', 41 record: { 42 type: 'object', 43 properties: { 44 text: { 45 type: 'string', 46 minLength: 10, 47 }, 48 }, 49 }, 50 }, 51 }, 52 }, 53 ], 54 collection: 'test.string.short', 55 record: { text: 'short' }, 56 }, 57 { 58 name: 'string-data-invalid-too-long', 59 lexicons: [ 60 { 61 lexicon: 1, 62 id: 'test.string.long', 63 defs: { 64 main: { 65 type: 'record', 66 key: 'tid', 67 record: { 68 type: 'object', 69 properties: { 70 text: { 71 type: 'string', 72 maxLength: 5, 73 }, 74 }, 75 }, 76 }, 77 }, 78 }, 79 ], 80 collection: 'test.string.long', 81 record: { text: 'this is too long' }, 82 }, 83 { 84 name: 'string-data-valid-enum', 85 lexicons: [ 86 { 87 lexicon: 1, 88 id: 'test.string.enumvalid', 89 defs: { 90 main: { 91 type: 'record', 92 key: 'tid', 93 record: { 94 type: 'object', 95 properties: { 96 color: { 97 type: 'string', 98 enum: ['red', 'blue'], 99 }, 100 }, 101 }, 102 }, 103 }, 104 }, 105 ], 106 collection: 'test.string.enumvalid', 107 record: { color: 'red' }, 108 }, 109 { 110 name: 'string-data-invalid-enum', 111 lexicons: [ 112 { 113 lexicon: 1, 114 id: 'test.string.enuminvalid', 115 defs: { 116 main: { 117 type: 'record', 118 key: 'tid', 119 record: { 120 type: 'object', 121 properties: { 122 color: { 123 type: 'string', 124 enum: ['red', 'blue'], 125 }, 126 }, 127 }, 128 }, 129 }, 130 }, 131 ], 132 collection: 'test.string.enuminvalid', 133 record: { color: 'green' }, 134 }, 135 { 136 name: 'string-data-invalid-wrong-type', 137 lexicons: [ 138 { 139 lexicon: 1, 140 id: 'test.string.wrongtype', 141 defs: { 142 main: { 143 type: 'record', 144 key: 'tid', 145 record: { 146 type: 'object', 147 properties: { 148 text: { 149 type: 'string', 150 }, 151 }, 152 }, 153 }, 154 }, 155 }, 156 ], 157 collection: 'test.string.wrongtype', 158 record: { text: 42 }, 159 }, 160 { 161 name: 'string-data-invalid-graphemes-too-short', 162 lexicons: [ 163 { 164 lexicon: 1, 165 id: 'test.string.graphshort', 166 defs: { 167 main: { 168 type: 'record', 169 key: 'tid', 170 record: { 171 type: 'object', 172 properties: { 173 text: { 174 type: 'string', 175 minGraphemes: 10, 176 }, 177 }, 178 }, 179 }, 180 }, 181 }, 182 ], 183 collection: 'test.string.graphshort', 184 record: { text: 'hi' }, 185 }, 186 { 187 name: 'string-data-invalid-graphemes-too-long', 188 lexicons: [ 189 { 190 lexicon: 1, 191 id: 'test.string.graphlong', 192 defs: { 193 main: { 194 type: 'record', 195 key: 'tid', 196 record: { 197 type: 'object', 198 properties: { 199 text: { 200 type: 'string', 201 maxGraphemes: 3, 202 }, 203 }, 204 }, 205 }, 206 }, 207 }, 208 ], 209 collection: 'test.string.graphlong', 210 record: { text: 'hello' }, 211 }, 212];