A plain JavaScript validator for AT Protocol lexicon schemas
at main 139 lines 3.1 kB view raw
1// Test inputs for array data validation 2 3export const arrayDataInputs = [ 4 { 5 name: 'array-data-valid-basic', 6 lexicons: [ 7 { 8 lexicon: 1, 9 id: 'test.array.data', 10 defs: { 11 main: { 12 type: 'record', 13 key: 'tid', 14 record: { 15 type: 'object', 16 properties: { 17 tags: { 18 type: 'array', 19 items: { type: 'string' }, 20 minLength: 1, 21 maxLength: 5, 22 }, 23 }, 24 }, 25 }, 26 }, 27 }, 28 ], 29 collection: 'test.array.data', 30 record: { tags: ['hello', 'world'] }, 31 }, 32 { 33 name: 'array-data-invalid-below-minLength', 34 lexicons: [ 35 { 36 lexicon: 1, 37 id: 'test.array.minlength', 38 defs: { 39 main: { 40 type: 'record', 41 key: 'tid', 42 record: { 43 type: 'object', 44 properties: { 45 tags: { 46 type: 'array', 47 items: { type: 'string' }, 48 minLength: 3, 49 }, 50 }, 51 }, 52 }, 53 }, 54 }, 55 ], 56 collection: 'test.array.minlength', 57 record: { tags: ['hello'] }, 58 }, 59 { 60 name: 'array-data-invalid-above-maxLength', 61 lexicons: [ 62 { 63 lexicon: 1, 64 id: 'test.array.maxlength', 65 defs: { 66 main: { 67 type: 'record', 68 key: 'tid', 69 record: { 70 type: 'object', 71 properties: { 72 tags: { 73 type: 'array', 74 items: { type: 'string' }, 75 maxLength: 2, 76 }, 77 }, 78 }, 79 }, 80 }, 81 }, 82 ], 83 collection: 'test.array.maxlength', 84 record: { tags: ['a', 'b', 'c'] }, 85 }, 86 { 87 name: 'array-data-invalid-item-type', 88 lexicons: [ 89 { 90 lexicon: 1, 91 id: 'test.array.itemtype', 92 defs: { 93 main: { 94 type: 'record', 95 key: 'tid', 96 record: { 97 type: 'object', 98 properties: { 99 tags: { 100 type: 'array', 101 items: { type: 'string' }, 102 }, 103 }, 104 }, 105 }, 106 }, 107 }, 108 ], 109 collection: 'test.array.itemtype', 110 record: { tags: ['hello', 42] }, 111 }, 112 { 113 name: 'array-data-invalid-empty-with-minLength', 114 lexicons: [ 115 { 116 lexicon: 1, 117 id: 'test.array.emptymin', 118 defs: { 119 main: { 120 type: 'record', 121 key: 'tid', 122 record: { 123 type: 'object', 124 properties: { 125 tags: { 126 type: 'array', 127 items: { type: 'string' }, 128 minLength: 1, 129 }, 130 }, 131 }, 132 }, 133 }, 134 }, 135 ], 136 collection: 'test.array.emptymin', 137 record: { tags: [] }, 138 }, 139];