@awesomeness-js/utils 1.2.8 → 1.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/utils/clean.js +1 -1
- package/tests/clean/array.test.js +43 -0
package/package.json
CHANGED
package/src/utils/clean.js
CHANGED
|
@@ -132,7 +132,7 @@ function cleanArray(arr, schema = {}, {
|
|
|
132
132
|
|
|
133
133
|
if(supposedToBeType === 'object'){
|
|
134
134
|
|
|
135
|
-
cleanedItem = cleanObject(item, schema.
|
|
135
|
+
cleanedItem = cleanObject(item, schema.items, {
|
|
136
136
|
testMode,
|
|
137
137
|
allOrNothing,
|
|
138
138
|
path: path ? `${path}.${key}` : key
|
|
@@ -134,6 +134,41 @@ const schemaForArrayOfObjects = {
|
|
|
134
134
|
}
|
|
135
135
|
};
|
|
136
136
|
|
|
137
|
+
const versesArray = [
|
|
138
|
+
{
|
|
139
|
+
book: 'GEN',
|
|
140
|
+
chapter: 1,
|
|
141
|
+
verse: 1,
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
book: 'PSA',
|
|
145
|
+
chapter: 23,
|
|
146
|
+
verse: 4,
|
|
147
|
+
}
|
|
148
|
+
];
|
|
149
|
+
|
|
150
|
+
const versesSchema = {
|
|
151
|
+
type: 'array',
|
|
152
|
+
required: true,
|
|
153
|
+
items: {
|
|
154
|
+
type: 'object',
|
|
155
|
+
properties: {
|
|
156
|
+
book: {
|
|
157
|
+
type: 'string',
|
|
158
|
+
required: true
|
|
159
|
+
},
|
|
160
|
+
chapter: {
|
|
161
|
+
type: 'integer',
|
|
162
|
+
required: true
|
|
163
|
+
},
|
|
164
|
+
verse: {
|
|
165
|
+
type: 'integer',
|
|
166
|
+
required: true
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
137
172
|
test('testStringArray', () => {
|
|
138
173
|
|
|
139
174
|
const x = utils.clean.array(testStringArray, schemaForStrings);
|
|
@@ -197,4 +232,12 @@ test('schemaForArrayOfObjects', () => {
|
|
|
197
232
|
|
|
198
233
|
expect(x).toStrictEqual(arrayOfObjects);
|
|
199
234
|
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
test('verses array of objects schema', () => {
|
|
238
|
+
|
|
239
|
+
const x = utils.clean.array(versesArray, versesSchema);
|
|
240
|
+
|
|
241
|
+
expect(x).toStrictEqual(versesArray);
|
|
242
|
+
|
|
200
243
|
});
|