We call this after validating the types, so we know the cast will never fail.
352335
private static <DeclaredT, RuntimeT> TypeCodec<DeclaredT> uncheckedCast(
      TypeCodec<RuntimeT> codec) {
    @SuppressWarnings("unchecked")
    TypeCodec<DeclaredT> result = (TypeCodec<DeclaredT>) codec;
    return result;
  }
1028075
private function preValidationCast()
    {
        $rules = $this->getAttributeRules();

        // Check each dirty attribute.
        foreach ($this->getDirty() as $key => $value) {
            // Get the rules.
            $rules_array = explode('|', array_get($rules, $key, ''));

            // First item is always the cast type.
            $cast = array_get($rules_array, 0, false);

            // Check if the value can be nullable.
            $nullable = in_array('nullable', $rules_array);

            switch ($cast) {
                case 'string':
                    $value = (string) $value;
                    break;
                case 'boolean':
                    $value = (bool) (int) $value;
                    break;
                case 'integer':
                    $value = (int) $value;
                    break;
                case 'numeric':
                    $value = (float) preg_replace('/[^0-9.-]*/', '', $value);
                    break;
            }

            // Value is empty, let's nullify.
            if (empty($value) && $nullable) {
                $value = null;
            }

            $this->attributes[$key] = $value;
        }
    }
360603
def Validate(self, value, **_):
    """"""
    # Assigning from same kind can allow us to skip verification since all
    # elements in a RepeatedFieldHelper already are coerced to the delegate
    # type. In that case we just make a copy. This only works when the value
    # wraps the same type as us.
    if (value.__class__ is RepeatedFieldHelper and
        value.type_descriptor is self.delegate):
      result = value.Copy()

    # Make sure the base class finds the value valid.
    else:
      # The value may be a generator here, so we just iterate over it.
      result = RepeatedFieldHelper(type_descriptor=self.delegate)
      result.Extend(value)

    return result
294348
def validate_type(value, types, **kwargs):
    
    if not is_value_of_any_type(value, types):
        raise ValidationError(MESSAGES['type']['invalid'].format(
            repr(value), get_type_for_value(value), types,
        ))
1185690
public boolean validateGlobalType(GlobalType globalType, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(globalType, diagnostics, context);
	}
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)
567270
def _clean(self, value):
        """"""
        if value is None:
            return None
        elif self.type_ is None:
            return value
        elif self.check_type(value):
            return value
        elif self.is_type_castable:  # noqa
            return self.type_(value)

        error_fmt = "%s must be a %s, not a %s"
        error = error_fmt % (self.name, self.type_, type(value))
        raise TypeError(error)
354903
def type
            name = (self.class.name or self.class.superclass.name or self.native_type.name)

            name.split("::").last.to_sym
        end
545841
function ensure (env, options, names) {
  for (let k of Object.keys(names)) {
    let v = names[k]

    if (options[v]) {
      env[k] = options[v]
      env[k + 'Cwd'] = true
    }
  }
}
1301843
private boolean verifyTypes()
    {
        SuccessAndResult<ThriftType> output = topologicalSort(thriftTypes, new Predicate<ThriftType>()
        {
            @Override
            public boolean apply(@Nullable ThriftType t)
            {
                ThriftProtocolType proto = checkNotNull(t).getProtocolType();
                if (proto == ThriftProtocolType.ENUM || proto == ThriftProtocolType.STRUCT) {
                    return verifyStruct(t, true);
                } else {
                    Preconditions.checkState(false, "Top-level non-enum and non-struct?");
                    return false;   // silence compiler
                }
            }
        });
        if (output.success) {
            thriftTypes = output.result;
            return true;
        } else {
            for (ThriftType t: output.result) {
                // we know it's gonna fail, we just want the precise error message
                verifyStruct(t, false);
            }
            return false;
        }
    }
347445
def validate_wrap(self, value, *types):
        '''  '''
        for type in types:
            if isinstance(value, type):
                break
        else:
            self._fail_validation_type(value, *types)

        if self.min is not None and value < self.min:
            self._fail_validation(value, 'Value too small')
        if self.max is not None and value > self.max:
            self._fail_validation(value, 'Value too large')
199920
function arrayOfTypeValidation(validator) {
  return withRequired(function arrayOfType(value) {
    if (!Array.isArray(value)) {
      throw `Value ${value} must be an array.`;
    }
    value.every(validator);
  });
}
551979
def validate_wrap(self, value):
        ''' 
        '''
        if not isinstance(value, self.type):
            self._fail_validation_type(value, self.type)
858928
def validate(self):
        """"""
        if not (isinstance(self.target_class, set) and
                all(isinstance(x, six.string_types) for x in self.target_class)):
            raise TypeError(u'Expected set of string target_class, got: {} {}'.format(
                type(self.target_class).__name__, self.target_class))

        for cls in self.target_class:
            validate_safe_string(cls)
139098
def must_be_same(self, klass):
        """"""
        if self.__class__ is not klass:
            self.__class__ = klass
            self._morph()
            self.clear()
1184979
protected function ensureNotEmpty() {
        $this->currentInstance = 0;
        while ($this->classIterator->valid() && !$this->load($this->classIterator->current(), 0)) {
            $this->classIterator->next();
        }
    }
1224927
function(data, castType) {
    data = data || {}

    // if it's already a record
    if (data.definition && data._exists) {
      if (this.add) this.add(data)
      return data
    }

    if (this.chained) {
      var record = this.model.new()
      if (this.definition.temporary) {
        record.definition = this.definition
      }

      record.__chainedModel = this
      record.set(data, castType)

      this.add(record)

      return record
    }

    return new this(data, castType)
  }