dist/ext/validation.js
function validateProperties(entity, properties, changedPropertyName, changedPropertyValue, currentPropertyValue) {
  var _this2 = this;

  // Validate default property values
  _lodash2.default.forEach(properties, function (propertyConfiguration, propertyName) {
    if (isValidationProperty(propertyConfiguration)) {
      // Run validation function
      var validatedValue = propertyName !== changedPropertyName ? entity[propertyName] : changedPropertyValue,
          resetValue = propertyName !== changedPropertyName ? null : currentPropertyValue,
          validation = propertyConfiguration.validate(validatedValue, entity);
      // Check if validation successful
      if (validation === undefined) {
        // Reset validation error
        delete entity.validation[propertyName];
      } else {
        // Store validation error
        entity.validation[propertyName] = new ValidationOutput({
          property: propertyName,
          value: validatedValue,
          message: validation
        });
        // If rejecting invalid values, reset value to current value
        if (_this2.rejectInvalidValues) {
          // Unset default value (wrap into EnTTBypassEverythingValue to bypass validation and watchers)
          entity[propertyName] = new _properties.EnTTBypassEverythingValue(resetValue);
        }
      }
    }
  });
}
function validateProperties(entity, properties, changedPropertyName, changedPropertyValue, currentPropertyValue) {
  var _this2 = this;

  // Validate default property values
  _lodash2.default.forEach(properties, function (propertyConfiguration, propertyName) {
    if (isValidationProperty(propertyConfiguration)) {
      // Run validation function
      var validatedValue = propertyName !== changedPropertyName ? entity[propertyName] : changedPropertyValue,
          resetValue = propertyName !== changedPropertyName ? null : currentPropertyValue,
          validation = propertyConfiguration.validate(validatedValue, entity);
      // Check if validation successful
      if (validation === undefined) {
        // Reset validation error
        delete entity.validation[propertyName];
      } else {
        // Store validation error
        entity.validation[propertyName] = new ValidationOutput({
          property: propertyName,
          value: validatedValue,
          message: validation
        });
        // If rejecting invalid values, reset value to current value
        if (_this2.rejectInvalidValues) {
          // Unset default value (wrap into EnTTBypassEverythingValue to bypass validation and watchers)
          entity[propertyName] = new _properties.EnTTBypassEverythingValue(resetValue);
        }
      }
    }
  });
}
function validateProperties ( entity , properties , changedPropertyName , changedPropertyValue , currentPropertyValue ) { var _this2 = this ; // Validate default property values _lodash2 . default . forEach ( properties , function ( propertyConfiguration , propertyName ) { if ( isValidationProperty ( propertyConfiguration ) ) { // Run validation function var validatedValue = propertyName !== changedPropertyName ? entity [ propertyName ] : changedPropertyValue , resetValue = propertyName !== changedPropertyName ? null : currentPropertyValue , validation = propertyConfiguration . validate ( validatedValue , entity ) ; // Check if validation successful if ( validation === undefined ) { // Reset validation error delete entity . validation [ propertyName ] ; } else { // Store validation error entity . validation [ propertyName ] = new ValidationOutput ( { property : propertyName , value : validatedValue , message : validation } ) ; // If rejecting invalid values, reset value to current value if ( _this2 . rejectInvalidValues ) { // Unset default value (wrap into EnTTBypassEverythingValue to bypass validation and watchers) entity [ propertyName ] = new _properties . EnTTBypassEverythingValue ( resetValue ) ; } } } } ) ; }
Performs property validation and outputs results to errors object
@param {any} entity Entity instance
@param {any} properties Entity's properties' configuration
@param {any} changedPropertyName Name of the property being validated
@param {any} changedPropertyValue Value being validated
@param {any} currentPropertyValue Current property value
Performs property validation and outputs results to errors object