code: def validate(object)
        sanitized_object = validate_type(object)
        validate_constraints(sanitized_object) unless sanitized_object.nil? && allow_nil?
        self.sanitized_object = sanitized_object
        true
      rescue ValidationError => e
        # Reset sanitized object.
        self.sanitized_object = nil
        raise e
      end
docs: Call +validate_type+ with the given +object+, apply the constraints
   and assign the sanitized object.