MCPcopy Index your code
hub / github.com/dataease/SQLBot / validator

Function validator

frontend/public/swagger-ui-bundle.js:38672–38755  ·  view source on GitHub ↗
(s, o, i, a)

Source from the content-addressed store, hash-verified

38670 if (!1 === a.test) throw new Do('Test operation failed', 'TEST_OPERATION_FAILED', i, o, s)
38671 return a.newDocument
38672 }
38673 function validator(s, o, i, a) {
38674 if ('object' != typeof s || null === s || Array.isArray(s))
38675 throw new Do('Operation is not an object', 'OPERATION_NOT_AN_OBJECT', o, s, i)
38676 if (!Fo[s.op])
38677 throw new Do(
38678 'Operation `op` property is not one of operations defined in RFC-6902',
38679 'OPERATION_OP_INVALID',
38680 o,
38681 s,
38682 i
38683 )
38684 if ('string' != typeof s.path)
38685 throw new Do(
38686 'Operation `path` property is not a string',
38687 'OPERATION_PATH_INVALID',
38688 o,
38689 s,
38690 i
38691 )
38692 if (0 !== s.path.indexOf('/') && s.path.length > 0)
38693 throw new Do(
38694 'Operation `path` property must start with "/"',
38695 'OPERATION_PATH_INVALID',
38696 o,
38697 s,
38698 i
38699 )
38700 if (('move' === s.op || 'copy' === s.op) && 'string' != typeof s.from)
38701 throw new Do(
38702 'Operation `from` property is not present (applicable in `move` and `copy` operations)',
38703 'OPERATION_FROM_REQUIRED',
38704 o,
38705 s,
38706 i
38707 )
38708 if (('add' === s.op || 'replace' === s.op || 'test' === s.op) && void 0 === s.value)
38709 throw new Do(
38710 'Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)',
38711 'OPERATION_VALUE_REQUIRED',
38712 o,
38713 s,
38714 i
38715 )
38716 if (('add' === s.op || 'replace' === s.op || 'test' === s.op) && hasUndefined(s.value))
38717 throw new Do(
38718 'Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)',
38719 'OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED',
38720 o,
38721 s,
38722 i
38723 )
38724 if (i)
38725 if ('add' == s.op) {
38726 var u = s.path.split('/').length,
38727 _ = a.split('/').length
38728 if (u !== _ + 1 && u !== _)
38729 throw new Do(

Callers 1

applyOperationFunction · 0.70

Calls 3

hasUndefinedFunction · 0.85
validateFunction · 0.85
isArrayMethod · 0.45

Tested by

no test coverage detected