Validates ambush function data object on create.

@param {Ambush} object Ambush function data.
@returns {bool} If it's valid or not.
350158
function _isValidAmbush(object) {
	return _isValidObject(object) &&
		_isValidId(object.id) &&
		_isUniqueId(null, object.id) &&
		_isValidCategory(object.category) &&
		_isValidAction(object.action);
}
975150
function assembleValidation(validation) {
  if (!_.isPlainObject(validation)) {
    validation = {rule: validation, params: []};
  }
  if (_.isString(validation.rule)) {
    var splitRule = validation.rule.split(':');
    validation.rule = splitRule[0];
    if (_.isEmpty(validation.params)) {
      validation.params = _.tail(splitRule);
    }
  } else if (!_.isFunction(validation.rule)) {
    throw new TypeError('Invalid validation');
  }
  return validation;
}
1269684
function error(utils) {
  const target = this._obj;
  isValidation(target);
  const error = target.error || null,
      json = JSON.stringify(target, null, '\t');
  this.assert(null !== error,
      '#{this} should have error but does not: ' + json,
      '#{this} should not not have error but does: ' + json
  );
  utils.flag(this, 'object', error);
}
655235
function validateArgs(func, intervalLength, options) {

    // Validate "func"
    if (typeof func !== 'function') {
        throw new TypeError('Argument 1, "func", must be a function.')
    }

    // Validate "intervalLength"
    if (typeof intervalLength === 'number') {
        if (!Number.isInteger(intervalLength) || intervalLength < 0) {
            throw new TypeError('Argument 2, "intervalLength", must be a non-negative integer or a function that returns a non-negative integer.')
        }
    } else if (typeof intervalLength !== 'function') {
        throw new TypeError('Argument 2, "intervalLength", must be a non-negative integer or a function that returns a non-negative integer.')
    }

    // Validate options...
    if (typeof options !== 'object') {
        throw new TypeError('Argument 3, "options", must be an object.')
    }

    // Validate passed keys
    const allowedKeys = ['iterations', 'stopOnError']

    Object.keys(options).forEach(key => {
        if (!allowedKeys.includes(key)) {
            throw new TypeError('Option "' + key + '" is not a valid option.')
        }
    })
    
    // validate "iterations" option (if passed)
    if (options.hasOwnProperty('iterations')) {
        if (options.iterations !== Infinity && (!Number.isInteger(options.iterations) || options.iterations < 1)) {
            throw new TypeError('Option "iterations" must be Infinity or an integer greater than 0.')
        }
    }
    
    // validate "stopOnError" option (if passed)
    if (options.hasOwnProperty('stopOnError')) {
        if (typeof options.stopOnError !== 'boolean') {
            throw new TypeError('Option "stopOnError" must be a boolean.')
        }
    }
}
217396
function injectAdditionalFunctions (funcs, additionalFunctions) {
  // Nothing to do if no additional function is given.
  if (no(additionalFunctions)) return

  /**
   * Validate and insert an additional function.
   */

  function injectAdditionalFunction (key) {
    var isAFunction = typeof additionalFunctions[key] === 'function'

    if (isAFunction) funcs[key] = additionalFunctions[key]
  }

  Object.keys(additionalFunctions)
    .forEach(injectAdditionalFunction)
}
812987
function booleanFalse(validatedObject, errorText) {
  if (!_.isBoolean(validatedObject) || validatedObject) {
    throw new ValidationError(errorText || 'Validated object is not False');
  }
  return validatedObject;
}
752556
def is_valid(obj: JSGValidateable, log: Optional[Union[TextIO, Logger]] = None) -> bool:
    
    return obj._is_valid(log)
839817
function ( object ) {
      this.__class__ = 'Unique';

      if ( 'object' === typeof object )
        this.key = object.key;

      this.validate = function ( array ) {
        var value, store = [];

        if ( !_isArray( array ) )
          throw new Violation( this, array, { value: Validator.errorCode.must_be_an_array } );

        for ( var i = 0; i < array.length; i++ ) {
          value = 'object' === typeof array[ i ] ? array[ i ][ this.key ] : array[ i ];

          if ( 'undefined' === typeof value )
            continue;

          if ( -1 !== store.indexOf( value ) )
            throw new Violation( this, array, { value: value } );

          store.push( value );
        }

        return true;
      };

      return this;
    }
1337850
function validateTextOperationJSON (op) {
  debug('validateTextOperationJSON %o', op)
  assertErr(Array.isArray(op), Error, 'operation must be an array', { op: op })
  assertErr(op.length, Error, 'operation cannot be empty', { op: op })
  var type
  var lastType = ''
  op.forEach(function (item) {
    if (typeof item === 'string') {
      // valid
      type = 'string'
      assertErr(lastType !== type, Error, 'invalid operation: cannot have repeating ' + type + 's')
      lastType = type
      return
    } else if (typeof item === 'number') {
      var isIntegerOrZero = (item === (item | 0))
      assertErr(isIntegerOrZero, Error, 'invalid operation: numbers must be integers')
      type = item === 0
        ? 'zero'
        : item > 0
          ? 'positive integer'
          : 'negative integer'
      assertErr(lastType !== type, Error, 'invalid operation: cannot have repeating ' + type + 's')
      lastType = type
    } else {
      throw new Error('invalid operation: must be an array of strings and numbers')
    }
  })
}
342084
function AssertionError(options) {
  merge(this, options);

  if (!options.message) {
    Object.defineProperty(this, "message", {
      get: function() {
        if (!this._message) {
          this._message = this.generateMessage();
          this.generatedMessage = true;
        }
        return this._message;
      },
      configurable: true,
      enumerable: false
    });
  }

  if (Error.captureStackTrace) {
    Error.captureStackTrace(this, this.stackStartFunction);
  } else {
    // non v8 browsers so we can have a stacktrace
    var err = new Error();
    if (err.stack) {
      var out = err.stack;

      if (this.stackStartFunction) {
        // try to strip useless frames
        var fn_name = functionName$1(this.stackStartFunction);
        var idx = out.indexOf("\n" + fn_name);
        if (idx >= 0) {
          // once we have located the function frame
          // we need to strip out everything before it (and its line)
          var next_line = out.indexOf("\n", idx + 1);
          out = out.substring(next_line + 1);
        }
      }

      this.stack = out;
    }
  }
}
1127266
function isValidObject(key) {
  const isValid = VALID_TRACKING_OBJECTS.indexOf(key) !== -1;
  if (!isValid) {
    console.log(chalk.red('Tracking Error:'));
    console.log(`"${key}" is invalid tracking object. Must be one of`, VALID_TRACKING_OBJECTS);
  }
  return isValid;
}
514816
function isValid(date) {
  return Object.prototype.toString.call(date) == '[object Date]' && !isNaN(date.getTime());
}
244095
function isArguments(object) {
        if (typeof object !== "object" || typeof object.length !== "number" ||
                getClass(object) === "Array") {
            return false;
        }
        if (typeof object.callee == "function") { return true; }
        try {
            object[object.length] = 6;
            delete object[object.length];
        } catch (e) {
            return true;
        }
        return false;
    }
470880
function validateUnit( objUnit, bRequireDefinitionOrChange, cb2 )
	{
		let bFound = false;
		_async.eachSeries
		(
			objUnit.authors,
			function( author, cb3 )
			{
				let sAddress = author.address;
				if ( -1 === arrFoundTrustMEAuthors.indexOf( sAddress ) )
				{
					//	not a witness - skip it
					return cb3();
				}

				//
				//	the latest definition chash of the witness
				//
				let definition_chash = assocDefinitionChashes[ sAddress ];
				if ( ! definition_chash )
				{
					throw Error( "definition chash not known for address " + sAddress );
				}
				if ( author.definition )
				{
					//
					//	do transaction for the first time
					//
					if ( _object_hash.getChash160( author.definition ) !== definition_chash )
					{
						return cb3( "definition doesn't hash to the expected value" );
					}

					assocDefinitions[ definition_chash ] = author.definition;
					bFound = true;
				}


				function handleAuthor()
				{
					//	FIX
					_validation.validateAuthorSignaturesWithoutReferences
					(
						author,
						objUnit,
						assocDefinitions[ definition_chash ],	//	definition JSON
						function( err )
						{
							if ( err )
							{
								return cb3( err );
							}

							//
							//	okay, definition is valid
							//
							for ( let i = 0; i < objUnit.messages.length; i++ )
							{
								let message = objUnit.messages[ i ];
								if ( 'address_definition_change' === message.app
									&& ( message.payload.address === sAddress ||
										1 === objUnit.authors.length && objUnit.authors[ 0 ].address === sAddress ) )
								{
									assocDefinitionChashes[ sAddress ] = message.payload.definition_chash;
									bFound = true;
								}
							}

							//	...
							cb3();
						}
					);
				}

				if ( assocDefinitions[ definition_chash ] )
				{
					return handleAuthor();
				}

				//
				//	only an address with money
				//	there is no transaction any more
				//
				_storage.readDefinition( _db, definition_chash,
				{
					ifFound : function( arrDefinition )
					{
						assocDefinitions[ definition_chash ] = arrDefinition;
						handleAuthor();
					},
					ifDefinitionNotFound : function( sDefinitionCHash )
					{
						throw Error( "definition " + definition_chash + " not found, address " + sAddress );
					}
				});
			},
			function( err )
			{
				if ( err )
				{
					return cb2( err );
				}

				if ( bRequireDefinitionOrChange && ! bFound )
				{
					//
					//	bRequireDefinitionOrChange always be false
					//	so, you will never arrive here so far
					//
					return cb2( "neither definition nor change" );
				}

				//	...
				cb2();
			}

		); // each authors
	}
1283075
function booleanTrue(validatedObject, errorText) {
  if (!_.isBoolean(validatedObject) || !validatedObject) {
    throw new ValidationError(errorText || 'Validated object is not True');
  }
  return validatedObject;
}
661241
function validate( opts, options ) {
	if ( !isObject( options ) ) {
		return new TypeError( 'invalid input argument. Options argument must be an object. Option: `' + options + '`.' );
	}
	if ( options.hasOwnProperty( 'flavor' ) ) {
		opts.flavor = options.flavor;
		if ( !isString( opts.flavor ) ) {
			return new TypeError( 'invalid option. Markdown flavor option must be a string primitive. Option: `' + opts.flavor + '`.' );
		}
	}
	return null;
}
705463
function validate (schema, data, key) {
  let value = data[key]
  const bool = value == null || value === ''
  const { required, type, validate, transform, elements } = schema
  const def = schema['default']
  // trigger error if undefined but required
  if (required && bool) throw new Error(`field ${key} is missing`)
  // coerce to type
  if (type && !bool) {
    let before = coerce(type, key, value)
    data[key] = elements
      ? (type === 'object' ? validator(before, elements) : before.map(item => validator(item, elements)))
      : before
  }
  // validate value
  if (validate) {
    const cb = check(validate, key)
    if (type === 'array') value.map(cb)
    else cb(value)
  }
  // apply default value
  if (def && bool) data[key] = def
  // apply transform
  if (transform && def == null) {
    data[key] = typeof transform === 'function'
      ? (type === 'array' ? value.map(transform) : transform(value))
      : transform
  }
}