Validates data types before being sent to dashboard. Disabled with this.novalidate=true (for tests).

@param {*} data - The value to be validated.
@param {string} expectedType - Valid output from typeof, or 'array'.
@param {string} errorMessage
777587
function (data, expectedType, errorMessage) {
            if (!this.novalidate) {
                if (data == null || ((expectedType === 'array') ? !Array.isArray(data) : typeof data !== expectedType)) {
                    throw new Error(this.transport.TAG + errorMessage);
                }
            }
        }
355809
def validate_type(prop, value, expected):
    

    # Validate on expected type(s), but ignore None: defaults handled elsewhere
    if value is not None and not isinstance(value, expected):
        _validation_error(prop, type(value).__name__, None, expected)
485017
function PostalDataValidator(data) {
  MessagingUserStatus.call(this, 'postal validator');

  if (typeof data.to === 'undefined') {
    // No to address given
    this.state.code = this.StatusCodes.MISSING;
    this.state.message = 'No "to" address given';

  } else if (typeof data.from === 'undefined') {
    // No from address given
    this.state.code = this.StatusCodes.MISSING;
    this.state.message = 'No "from" address given';

  } else if (typeof data.file === 'undefined') {
    // No file given
    this.state.code = this.StatusCodes.MISSING;
    this.state.message = 'No file given';

  } else {
    // Input data is valid
    this.state.code = this.StatusCodes.VALID;
    this.state.message = 'Ok';
  }
}
65260
def AssertType(value, expected_type):
  
  if not isinstance(value, expected_type):
    message = "Expected type `%r`, but got value `%r` of type `%s`"
    message %= (expected_type, value, type(value))
    raise TypeError(message)
629295
private function assertElementValidationMessage($type, $element, $expectedMessage)
    {
        $element = sprintf('%s_%s', $type, str_replace(' ', '_', $element));
        Assert::true($this->updatePage->checkValidationMessageFor($element, $expectedMessage));
    }
319351
function getError (type, expected, actual) {
        return {
            attribute: type,
            expected: expected,
            actual: actual,
            message: getMsg(type, expected)
        };
    }
1359194
function ValidationFailed(reason) {
  Error.captureStackTrace(this, this.constructor);
  this.type = 'bad_request';
  this.statusCode = 400;
  this.message = 'Request validation failed';
  this.reason = reason;
}
825688
public static function InvalidTypeException($expectedType, $key, $value) {
        throw new InvalidTypeException($expectedType, $key, is_array($value) ? serialize($value) : $value);
    }
872854
function isUndefined(value, message, id) {
    if (message === void 0) { message = ''; }
    if (id === void 0) { id = ''; }
    if (this.enabled && value !== undefined) {
        throw TypeException.unexpectedType(assertionTypes.IS_UNDEFINED, value, '<undefined>', message, id);
    }
}
324529
function (sequenceIndex, requestType, data) {
		'use strict';
		var message = "Request #" + (sequenceIndex + 1) + " (" + requestType + ")";
		if (data.message) {
			message += ": " + data.message;
		}
		data.message = message;
		
		// the message has information that should be displayed by the test runner
		data.generatedMessage = false;
		
		data.name = "AssertionError";
		throw new AssertionError(message, data);
	}
1059797
function insertCallback(error, data) {
  console.log(require('util').inspect(error ? error.message : data, { showHidden: true, colors: true, depth: 2 }));
}
206591
function addError(data, error) {
	if (!data.error) {
		data.error = [];
	}
	error.lineNumber = data.lineNumber;
	data.error.push(error);
}
972741
function (data) {
        var msg = messages.unwrap(data);
        if (!msg) {
            logger.error("routeMessage got a NULL coap message ", { coreID: this.getHexCoreID() });
            return;
        }

        this._lastMessageTime = new Date();

        //should be adequate
        var msgCode = msg.getCode();
        if ((msgCode > Message.Code.EMPTY) && (msgCode <= Message.Code.DELETE)) {
            //probably a request
            msg._type = messages.getRequestType(msg);
        }

        if (!msg._type) {
            msg._type = this.getResponseType(msg.getTokenString());
        }

        //console.log("core got message of type " + msg._type + " with token " + msg.getTokenString() + " " + messages.getRequestType(msg));

        if (msg.isAcknowledgement()) {
            if (!msg._type) {
                //no type, can't route it.
                msg._type = 'PingAck';
            }
            this.emit(('msg_' + msg._type).toLowerCase(), msg);
            return;
        }


        var nextPeerCounter = ++this.recvCounter;
        if (nextPeerCounter > 65535) {
            //TODO: clean me up! (I need settings, and maybe belong elsewhere)
            this.recvCounter = nextPeerCounter = 0;
        }

        if (msg.isEmpty() && msg.isConfirmable()) {
            this._lastCorePing = new Date();
            //var delta = (this._lastCorePing - this._connStartTime) / 1000.0;
            //logger.log("core ping @ ", delta, " seconds ", { coreID: this.getHexCoreID() });
            this.sendReply("PingAck", msg.getId());
            return;
        }

        if (!msg || (msg.getId() != nextPeerCounter)) {
            logger.log("got counter ", msg.getId(), " expecting ", nextPeerCounter, { coreID: this.getHexCoreID() });

            if (msg._type == "Ignored") {
                //don't ignore an ignore...
                this.disconnect("Got an Ignore");
                return;
            }

            //this.sendMessage("Ignored", null, {}, null, null);
            this.disconnect("Bad Counter");
            return;
        }

        this.emit(('msg_' + msg._type).toLowerCase(), msg);
    }
338177
function validated(invalid){
            if (invalid) { return callback(invalid) }
            if(options.coerce){crudUtils.coerceData(options,coerced())}
            else{coerced(null,options.data)}
        }
1278842
def data_type=(new_val)
      return nil if @data_type == new_val
      raise JSS::InvalidDataError, "data_type must be a string, one of: #{DATA_TYPES.join(', ')}" unless DATA_TYPES.include? new_val
      @data_type = new_val
      @need_to_update = true
    end
381804
def _validate_type(self, data_type, field, value):
        
        if not data_type:
            return

        types = (data_type,) if isinstance(data_type, _str_type) else data_type

        for _type in types:
            # TODO remove this block on next major release
            # this implementation still supports custom type validation methods
            type_definition = self.types_mapping.get(_type)
            if type_definition is not None:
                matched = isinstance(value, type_definition.included_types) \
                    and not isinstance(value, type_definition.excluded_types)
            else:
                type_handler = self.__get_rule_handler('validate_type', _type)
                matched = type_handler(value)
            if matched:
                return

            # TODO uncomment this block on next major release
            #      when _validate_type_* methods were deprecated:
            # type_definition = self.types_mapping[_type]
            # if isinstance(value, type_definition.included_types) \
            #         and not isinstance(value, type_definition.excluded_types):  # noqa 501
            #     return

        self._error(field, errors.BAD_TYPE)
        self._drop_remaining_rules()
807701
function ValidationError(message, errors) {
	Error.call(this, message);

	if (Error.captureStackTrace) {
		Error.captureStackTrace(this, ValidationError);
	}

	this.message = message;
	this.errors = errors;
}