lib/types/any.js
function(ref, condition) {
    condition = condition || {};

    utils.assert(
      condition.then || condition.otherwise ,
      'one of condition.then or condition.otherwise must be existed'
    );
    utils.assert(
      !condition.then || (condition.then && condition.then.isOvt),
      'condition.then must be a valid ovt schema'
    );
    utils.assert(
      !condition.otherwise || (condition.otherwise && condition.otherwise.isOvt),
      'condition.otherwise must be a valid ovt schema'
    );

    if (utils.isString(ref)) ref = utils.ref(ref);

    utils.assert(utils.isRef(ref), 'ref must be a valid string or ref object');

    // overwrite `then` and `otherwise` options to allow unknown and not stripped
    let options = { allowUnknown: true, stripUnknown: false };

    if (condition.then) condition.then = condition.then.options(options);
    if (condition.otherwise) condition.otherwise = condition.otherwise.options(options);

    return [ref, condition];
  }
function(ref, condition) {
    condition = condition || {};

    utils.assert(
      condition.then || condition.otherwise ,
      'one of condition.then or condition.otherwise must be existed'
    );
    utils.assert(
      !condition.then || (condition.then && condition.then.isOvt),
      'condition.then must be a valid ovt schema'
    );
    utils.assert(
      !condition.otherwise || (condition.otherwise && condition.otherwise.isOvt),
      'condition.otherwise must be a valid ovt schema'
    );

    if (utils.isString(ref)) ref = utils.ref(ref);

    utils.assert(utils.isRef(ref), 'ref must be a valid string or ref object');

    // overwrite `then` and `otherwise` options to allow unknown and not stripped
    let options = { allowUnknown: true, stripUnknown: false };

    if (condition.then) condition.then = condition.then.options(options);
    if (condition.otherwise) condition.otherwise = condition.otherwise.options(options);

    return [ref, condition];
  }
function ( ref , condition ) { condition = condition || { } ; utils . assert ( condition . then || condition . otherwise , 'one of condition.then or condition.otherwise must be existed' ) ; utils . assert ( ! condition . then || ( condition . then && condition . then . isOvt ) , 'condition.then must be a valid ovt schema' ) ; utils . assert ( ! condition . otherwise || ( condition . otherwise && condition . otherwise . isOvt ) , 'condition.otherwise must be a valid ovt schema' ) ; if ( utils . isString ( ref ) ) ref = utils . ref ( ref ) ; utils . assert ( utils . isRef ( ref ) , 'ref must be a valid string or ref object' ) ; // overwrite `then` and `otherwise` options to allow unknown and not stripped let options = { allowUnknown : true , stripUnknown : false } ; if ( condition . then ) condition . then = condition . then . options ( options ) ; if ( condition . otherwise ) condition . otherwise = condition . otherwise . options ( options ) ; return [ ref , condition ] ; }
Check and parse ref and condition
Check and parse ref and condition