@orion-js/schema
Advanced tools
Comparing version 0.0.34 to 0.0.38
@@ -137,4 +137,4 @@ 'use strict'; | ||
test('gives an error if a optional object is present and has missing values', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() { | ||
var errors; | ||
test('dont give error when array is optional and its not passed', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() { | ||
var schema, errors; | ||
return regeneratorRuntime.wrap(function _callee4$(_context4) { | ||
@@ -144,4 +144,38 @@ while (1) { | ||
case 0: | ||
_context4.next = 2; | ||
schema = { | ||
name: { | ||
type: String | ||
}, | ||
tags: { | ||
type: [String], | ||
optional: true | ||
} | ||
}; | ||
_context4.next = 3; | ||
return (0, _index2.default)(schema, { | ||
name: 'Nicolás López', | ||
tags: [] | ||
}); | ||
case 3: | ||
errors = _context4.sent; | ||
expect(errors).toBeNull(); | ||
case 5: | ||
case 'end': | ||
return _context4.stop(); | ||
} | ||
} | ||
}, _callee4, undefined); | ||
}))); | ||
test('gives an error if a optional object is present and has missing values', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() { | ||
var errors; | ||
return regeneratorRuntime.wrap(function _callee5$(_context5) { | ||
while (1) { | ||
switch (_context5.prev = _context5.next) { | ||
case 0: | ||
_context5.next = 2; | ||
return (0, _index2.default)(schema, { | ||
firstName: 'Nicolás', | ||
@@ -156,3 +190,3 @@ lastName: 'López', | ||
case 2: | ||
errors = _context4.sent; | ||
errors = _context5.sent; | ||
@@ -165,13 +199,13 @@ expect(errors).toEqual({ | ||
case 'end': | ||
return _context4.stop(); | ||
return _context5.stop(); | ||
} | ||
} | ||
}, _callee4, undefined); | ||
}, _callee5, undefined); | ||
}))); | ||
test('can check errors in deeply nested keys', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() { | ||
test('can check errors in deeply nested keys', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() { | ||
var children, mother, family, deepSchema, errors; | ||
return regeneratorRuntime.wrap(function _callee5$(_context5) { | ||
return regeneratorRuntime.wrap(function _callee6$(_context6) { | ||
while (1) { | ||
switch (_context5.prev = _context5.next) { | ||
switch (_context6.prev = _context6.next) { | ||
case 0: | ||
@@ -214,3 +248,3 @@ children = { | ||
}; | ||
_context5.next = 6; | ||
_context6.next = 6; | ||
return (0, _index2.default)(deepSchema, { | ||
@@ -239,3 +273,3 @@ name: 'Nicolás', | ||
case 6: | ||
errors = _context5.sent; | ||
errors = _context6.sent; | ||
@@ -250,13 +284,13 @@ expect(errors).toEqual({ | ||
case 'end': | ||
return _context5.stop(); | ||
return _context6.stop(); | ||
} | ||
} | ||
}, _callee5, undefined); | ||
}, _callee6, undefined); | ||
}))); | ||
test('can validate object type with custom validation', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() { | ||
test('can validate object type with custom validation', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8() { | ||
var person, schema; | ||
return regeneratorRuntime.wrap(function _callee7$(_context7) { | ||
return regeneratorRuntime.wrap(function _callee8$(_context8) { | ||
while (1) { | ||
switch (_context7.prev = _context7.next) { | ||
switch (_context8.prev = _context8.next) { | ||
case 0: | ||
@@ -270,15 +304,15 @@ person = { | ||
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() { | ||
return regeneratorRuntime.wrap(function _callee6$(_context6) { | ||
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() { | ||
return regeneratorRuntime.wrap(function _callee7$(_context7) { | ||
while (1) { | ||
switch (_context6.prev = _context6.next) { | ||
switch (_context7.prev = _context7.next) { | ||
case 0: | ||
return _context6.abrupt('return', value.name === 'Nicolás' ? null : 'no'); | ||
return _context7.abrupt('return', value.name === 'Nicolás' ? null : 'no'); | ||
case 1: | ||
case 'end': | ||
return _context6.stop(); | ||
return _context7.stop(); | ||
} | ||
} | ||
}, _callee6, _this); | ||
}, _callee7, _this); | ||
}))(); | ||
@@ -292,4 +326,4 @@ } | ||
}; | ||
_context7.t0 = expect; | ||
_context7.next = 5; | ||
_context8.t0 = expect; | ||
_context8.next = 5; | ||
return (0, _index2.default)(schema, { | ||
@@ -300,6 +334,6 @@ person: { name: 'Nicolás' } | ||
case 5: | ||
_context7.t1 = _context7.sent; | ||
(0, _context7.t0)(_context7.t1).toBeNull(); | ||
_context7.t2 = expect; | ||
_context7.next = 10; | ||
_context8.t1 = _context8.sent; | ||
(0, _context8.t0)(_context8.t1).toBeNull(); | ||
_context8.t2 = expect; | ||
_context8.next = 10; | ||
return (0, _index2.default)(schema, { | ||
@@ -310,21 +344,21 @@ person: { name: 'Joaquin' } | ||
case 10: | ||
_context7.t3 = _context7.sent; | ||
_context7.t4 = { | ||
_context8.t3 = _context8.sent; | ||
_context8.t4 = { | ||
person: 'no' | ||
}; | ||
(0, _context7.t2)(_context7.t3).toEqual(_context7.t4); | ||
(0, _context8.t2)(_context8.t3).toEqual(_context8.t4); | ||
case 13: | ||
case 'end': | ||
return _context7.stop(); | ||
return _context8.stop(); | ||
} | ||
} | ||
}, _callee7, undefined); | ||
}, _callee8, undefined); | ||
}))); | ||
test('skip child validation if specified', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9() { | ||
test('skip child validation if specified', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10() { | ||
var person, schema, errors; | ||
return regeneratorRuntime.wrap(function _callee9$(_context9) { | ||
return regeneratorRuntime.wrap(function _callee10$(_context10) { | ||
while (1) { | ||
switch (_context9.prev = _context9.next) { | ||
switch (_context10.prev = _context10.next) { | ||
case 0: | ||
@@ -341,15 +375,15 @@ person = { | ||
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8() { | ||
return regeneratorRuntime.wrap(function _callee8$(_context8) { | ||
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9() { | ||
return regeneratorRuntime.wrap(function _callee9$(_context9) { | ||
while (1) { | ||
switch (_context8.prev = _context8.next) { | ||
switch (_context9.prev = _context9.next) { | ||
case 0: | ||
return _context8.abrupt('return', value.firstName === 'Nicolás'); | ||
return _context9.abrupt('return', value.firstName === 'Nicolás'); | ||
case 1: | ||
case 'end': | ||
return _context8.stop(); | ||
return _context9.stop(); | ||
} | ||
} | ||
}, _callee8, _this2); | ||
}, _callee9, _this2); | ||
}))(); | ||
@@ -363,4 +397,4 @@ } | ||
}; | ||
_context9.t0 = expect; | ||
_context9.next = 5; | ||
_context10.t0 = expect; | ||
_context10.next = 5; | ||
return (0, _index2.default)(schema, { | ||
@@ -371,5 +405,5 @@ persons: [{ firstName: 'Nicolás' }] | ||
case 5: | ||
_context9.t1 = _context9.sent; | ||
(0, _context9.t0)(_context9.t1).toBeNull(); | ||
_context9.next = 9; | ||
_context10.t1 = _context10.sent; | ||
(0, _context10.t0)(_context10.t1).toBeNull(); | ||
_context10.next = 9; | ||
return (0, _index2.default)(schema, { | ||
@@ -380,3 +414,3 @@ persons: [{ firstName: 'Joaquin' }] | ||
case 9: | ||
errors = _context9.sent; | ||
errors = _context10.sent; | ||
@@ -389,13 +423,13 @@ expect(errors).toEqual({ | ||
case 'end': | ||
return _context9.stop(); | ||
return _context10.stop(); | ||
} | ||
} | ||
}, _callee9, undefined); | ||
}, _callee10, undefined); | ||
}))); | ||
test('pass currentDoc validating arrays', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12() { | ||
test('pass currentDoc validating arrays', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13() { | ||
var aItem, doc, item, schema; | ||
return regeneratorRuntime.wrap(function _callee12$(_context12) { | ||
return regeneratorRuntime.wrap(function _callee13$(_context13) { | ||
while (1) { | ||
switch (_context12.prev = _context12.next) { | ||
switch (_context13.prev = _context13.next) { | ||
case 0: | ||
@@ -407,10 +441,10 @@ aItem = { name: 'Nicolás' }; | ||
type: String, | ||
custom: function custom(name, _ref9) { | ||
custom: function custom(name, _ref10) { | ||
var _this3 = this; | ||
var currentDoc = _ref9.currentDoc; | ||
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10() { | ||
return regeneratorRuntime.wrap(function _callee10$(_context10) { | ||
var currentDoc = _ref10.currentDoc; | ||
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11() { | ||
return regeneratorRuntime.wrap(function _callee11$(_context11) { | ||
while (1) { | ||
switch (_context10.prev = _context10.next) { | ||
switch (_context11.prev = _context11.next) { | ||
case 0: | ||
@@ -421,6 +455,6 @@ expect(currentDoc).toBe(aItem); | ||
case 'end': | ||
return _context10.stop(); | ||
return _context11.stop(); | ||
} | ||
} | ||
}, _callee10, _this3); | ||
}, _callee11, _this3); | ||
}))(); | ||
@@ -433,10 +467,10 @@ } | ||
type: [item], | ||
custom: function custom(items, _ref10) { | ||
custom: function custom(items, _ref11) { | ||
var _this4 = this; | ||
var currentDoc = _ref10.currentDoc; | ||
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11() { | ||
return regeneratorRuntime.wrap(function _callee11$(_context11) { | ||
var currentDoc = _ref11.currentDoc; | ||
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12() { | ||
return regeneratorRuntime.wrap(function _callee12$(_context12) { | ||
while (1) { | ||
switch (_context11.prev = _context11.next) { | ||
switch (_context12.prev = _context12.next) { | ||
case 0: | ||
@@ -447,6 +481,6 @@ expect(currentDoc).toBe(doc); | ||
case 'end': | ||
return _context11.stop(); | ||
return _context12.stop(); | ||
} | ||
} | ||
}, _callee11, _this4); | ||
}, _callee12, _this4); | ||
}))(); | ||
@@ -459,3 +493,3 @@ } | ||
expect.assertions(2); | ||
_context12.next = 7; | ||
_context13.next = 7; | ||
return (0, _index2.default)(schema, doc); | ||
@@ -465,13 +499,13 @@ | ||
case 'end': | ||
return _context12.stop(); | ||
return _context13.stop(); | ||
} | ||
} | ||
}, _callee12, undefined); | ||
}, _callee13, undefined); | ||
}))); | ||
test('pass currentDoc validating complex schemas', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee20() { | ||
test('pass currentDoc validating complex schemas', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee21() { | ||
var aCar, aMom, aItem, doc, car, mom, item, schema; | ||
return regeneratorRuntime.wrap(function _callee20$(_context20) { | ||
return regeneratorRuntime.wrap(function _callee21$(_context21) { | ||
while (1) { | ||
switch (_context20.prev = _context20.next) { | ||
switch (_context21.prev = _context21.next) { | ||
case 0: | ||
@@ -485,10 +519,10 @@ aCar = { brand: 'Jeep' }; | ||
type: String, | ||
custom: function custom(value, _ref12) { | ||
custom: function custom(value, _ref13) { | ||
var _this5 = this; | ||
var currentDoc = _ref12.currentDoc; | ||
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13() { | ||
return regeneratorRuntime.wrap(function _callee13$(_context13) { | ||
var currentDoc = _ref13.currentDoc; | ||
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14() { | ||
return regeneratorRuntime.wrap(function _callee14$(_context14) { | ||
while (1) { | ||
switch (_context13.prev = _context13.next) { | ||
switch (_context14.prev = _context14.next) { | ||
case 0: | ||
@@ -500,6 +534,6 @@ expect(value).toEqual(aCar.brand); | ||
case 'end': | ||
return _context13.stop(); | ||
return _context14.stop(); | ||
} | ||
} | ||
}, _callee13, _this5); | ||
}, _callee14, _this5); | ||
}))(); | ||
@@ -511,6 +545,6 @@ } | ||
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14() { | ||
return regeneratorRuntime.wrap(function _callee14$(_context14) { | ||
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15() { | ||
return regeneratorRuntime.wrap(function _callee15$(_context15) { | ||
while (1) { | ||
switch (_context14.prev = _context14.next) { | ||
switch (_context15.prev = _context15.next) { | ||
case 0: | ||
@@ -522,6 +556,6 @@ expect(value).toEqual(aMom.car); | ||
case 'end': | ||
return _context14.stop(); | ||
return _context15.stop(); | ||
} | ||
} | ||
}, _callee14, _this6); | ||
}, _callee15, _this6); | ||
}))(); | ||
@@ -533,10 +567,10 @@ } | ||
type: String, | ||
custom: function custom(value, _ref13) { | ||
custom: function custom(value, _ref14) { | ||
var _this7 = this; | ||
var currentDoc = _ref13.currentDoc; | ||
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15() { | ||
return regeneratorRuntime.wrap(function _callee15$(_context15) { | ||
var currentDoc = _ref14.currentDoc; | ||
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16() { | ||
return regeneratorRuntime.wrap(function _callee16$(_context16) { | ||
while (1) { | ||
switch (_context15.prev = _context15.next) { | ||
switch (_context16.prev = _context16.next) { | ||
case 0: | ||
@@ -548,6 +582,6 @@ expect(value).toEqual(aMom.name); | ||
case 'end': | ||
return _context15.stop(); | ||
return _context16.stop(); | ||
} | ||
} | ||
}, _callee15, _this7); | ||
}, _callee16, _this7); | ||
}))(); | ||
@@ -558,11 +592,11 @@ } | ||
type: car, | ||
custom: function custom(value, _ref14) { | ||
custom: function custom(value, _ref15) { | ||
var _this8 = this; | ||
var currentDoc = _ref14.currentDoc, | ||
doc = _ref14.doc; | ||
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16() { | ||
return regeneratorRuntime.wrap(function _callee16$(_context16) { | ||
var currentDoc = _ref15.currentDoc, | ||
doc = _ref15.doc; | ||
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee17() { | ||
return regeneratorRuntime.wrap(function _callee17$(_context17) { | ||
while (1) { | ||
switch (_context16.prev = _context16.next) { | ||
switch (_context17.prev = _context17.next) { | ||
case 0: | ||
@@ -574,6 +608,6 @@ expect(value).toEqual(aMom.car); | ||
case 'end': | ||
return _context16.stop(); | ||
return _context17.stop(); | ||
} | ||
} | ||
}, _callee16, _this8); | ||
}, _callee17, _this8); | ||
}))(); | ||
@@ -586,10 +620,10 @@ } | ||
type: String, | ||
custom: function custom(value, _ref15) { | ||
custom: function custom(value, _ref16) { | ||
var _this9 = this; | ||
var currentDoc = _ref15.currentDoc; | ||
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee17() { | ||
return regeneratorRuntime.wrap(function _callee17$(_context17) { | ||
var currentDoc = _ref16.currentDoc; | ||
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee18() { | ||
return regeneratorRuntime.wrap(function _callee18$(_context18) { | ||
while (1) { | ||
switch (_context17.prev = _context17.next) { | ||
switch (_context18.prev = _context18.next) { | ||
case 0: | ||
@@ -601,6 +635,6 @@ expect(value).toEqual(aItem.name); | ||
case 'end': | ||
return _context17.stop(); | ||
return _context18.stop(); | ||
} | ||
} | ||
}, _callee17, _this9); | ||
}, _callee18, _this9); | ||
}))(); | ||
@@ -611,10 +645,10 @@ } | ||
type: mom, | ||
custom: function custom(value, _ref16) { | ||
custom: function custom(value, _ref17) { | ||
var _this10 = this; | ||
var currentDoc = _ref16.currentDoc; | ||
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee18() { | ||
return regeneratorRuntime.wrap(function _callee18$(_context18) { | ||
var currentDoc = _ref17.currentDoc; | ||
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee19() { | ||
return regeneratorRuntime.wrap(function _callee19$(_context19) { | ||
while (1) { | ||
switch (_context18.prev = _context18.next) { | ||
switch (_context19.prev = _context19.next) { | ||
case 0: | ||
@@ -626,6 +660,6 @@ expect(value).toEqual(aItem.mom); | ||
case 'end': | ||
return _context18.stop(); | ||
return _context19.stop(); | ||
} | ||
} | ||
}, _callee18, _this10); | ||
}, _callee19, _this10); | ||
}))(); | ||
@@ -638,10 +672,10 @@ } | ||
type: [item], | ||
custom: function custom(value, _ref17) { | ||
custom: function custom(value, _ref18) { | ||
var _this11 = this; | ||
var currentDoc = _ref17.currentDoc; | ||
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee19() { | ||
return regeneratorRuntime.wrap(function _callee19$(_context19) { | ||
var currentDoc = _ref18.currentDoc; | ||
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee20() { | ||
return regeneratorRuntime.wrap(function _callee20$(_context20) { | ||
while (1) { | ||
switch (_context19.prev = _context19.next) { | ||
switch (_context20.prev = _context20.next) { | ||
case 0: | ||
@@ -653,6 +687,6 @@ expect(value).toEqual(doc.items); | ||
case 'end': | ||
return _context19.stop(); | ||
return _context20.stop(); | ||
} | ||
} | ||
}, _callee19, _this11); | ||
}, _callee20, _this11); | ||
}))(); | ||
@@ -665,3 +699,3 @@ } | ||
expect.assertions(14); | ||
_context20.next = 11; | ||
_context21.next = 11; | ||
return (0, _index2.default)(schema, doc); | ||
@@ -671,6 +705,6 @@ | ||
case 'end': | ||
return _context20.stop(); | ||
return _context21.stop(); | ||
} | ||
} | ||
}, _callee20, undefined); | ||
}, _callee21, undefined); | ||
}))); |
{ | ||
"name": "@orion-js/schema", | ||
"version": "0.0.34", | ||
"version": "0.0.38", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "author": "nicolaslopezj", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
154511
3866