lib/validate.js
function checkFunctions (impl, schema) {
  const children = schema.describe().children
  const ret = { ok: true }
  for (let i in children) {
    if (impl.hasOwnProperty(i) && children.hasOwnProperty(i)) {
      if (children[ i ].flags && children[ i ].flags.func === true) {
        const func = impl[ i ]
        const funcSig = utils.parseFuncSig(func)
        let expectedArgs

        if (children[ i ].meta) {
          expectedArgs = children[ i ].meta[ 0 ].args

          if (!sameArray(funcSig, expectedArgs)) {
            ret.ok = false
            ret.message = errors.invalidSignature(i, expectedArgs, funcSig)
          }

          if (funcSig.length !== expectedArgs.length) {
            ret.ok = false
            ret.message = errors
              .unexpectedArgsLength(i, expectedArgs.length, funcSig.length)
          }
        } else {
          if (typeof impl[ i ] !== 'function') {
            ret.ok = false
            ret.message = `Property '${i}' is not a function!`
          }
        }

        if (!ret.ok) {
          return ret
        }
      }
    }
  }
  return ret
}
function checkFunctions (impl, schema) {
  const children = schema.describe().children
  const ret = { ok: true }
  for (let i in children) {
    if (impl.hasOwnProperty(i) && children.hasOwnProperty(i)) {
      if (children[ i ].flags && children[ i ].flags.func === true) {
        const func = impl[ i ]
        const funcSig = utils.parseFuncSig(func)
        let expectedArgs

        if (children[ i ].meta) {
          expectedArgs = children[ i ].meta[ 0 ].args

          if (!sameArray(funcSig, expectedArgs)) {
            ret.ok = false
            ret.message = errors.invalidSignature(i, expectedArgs, funcSig)
          }

          if (funcSig.length !== expectedArgs.length) {
            ret.ok = false
            ret.message = errors
              .unexpectedArgsLength(i, expectedArgs.length, funcSig.length)
          }
        } else {
          if (typeof impl[ i ] !== 'function') {
            ret.ok = false
            ret.message = `Property '${i}' is not a function!`
          }
        }

        if (!ret.ok) {
          return ret
        }
      }
    }
  }
  return ret
}
function checkFunctions ( impl , schema ) { const children = schema . describe ( ) . children const ret = { ok : true } for ( let i in children ) { if ( impl . hasOwnProperty ( i ) && children . hasOwnProperty ( i ) ) { if ( children [ i ] . flags && children [ i ] . flags . func === true ) { const func = impl [ i ] const funcSig = utils . parseFuncSig ( func ) let expectedArgs if ( children [ i ] . meta ) { expectedArgs = children [ i ] . meta [ 0 ] . args if ( ! sameArray ( funcSig , expectedArgs ) ) { ret . ok = false ret . message = errors . invalidSignature ( i , expectedArgs , funcSig ) } if ( funcSig . length !== expectedArgs . length ) { ret . ok = false ret . message = errors . unexpectedArgsLength ( i , expectedArgs . length , funcSig . length ) } } else { if ( typeof impl [ i ] !== 'function' ) { ret . ok = false ret . message = ` ${ i } ` } } if ( ! ret . ok ) { return ret } } } } return ret }
Does some funky joi object parsing and parses the function signature to
extract parameter names
Does some funky joi object parsing and parses the function signature to extract parameter names