Called to validate user input. Just return a hash of errors if there are any
509222
def errors
      errs = []

      # Make sure that every field is filled out
      self.class.fields.except(:project_id).each_with_object({}) do |(field_name, field_options), h|
        if options[field_name].blank?
          errs << "#{field_options[:label]} must be present"
        end
      end

      # We can only perform the other tests if the necessary values are at least present
      return {:base => errs.to_sentence} unless errs.size.zero?

      # Check if the given endpoint actually exists
      unless gitlab_endpoint_exists?(options[:endpoint])
        errs << 'No Gitlab installation was found under the given URL'
        return {:base => errs.to_sentence}
      end

      # Check if a user by the given token exists
      unless gitlab_user_exists?(options[:endpoint], options[:api_token])
        errs << 'No user with the given API token was found'
        return {:base => errs.to_sentence}
      end

      # Check if there is a project with the given name on the server
      unless gitlab_project_id(options[:endpoint], options[:api_token], options[:path_with_namespace])
        errs << "A project named '#{options[:path_with_namespace]}' could not be found on the server.
                 Please make sure to enter it exactly as it appears in your address bar in Gitlab (case sensitive)"
        return {:base => errs.to_sentence}
      end

      {}
    end
366285
def validate(self, instance, value):                                       #pylint: disable=inconsistent-return-statements
        """"""
        if not isinstance(value, string_types):
            self.error(instance, value)
        for key, val in self.choices.items():
            test_value = value if self.case_sensitive else value.upper()
            test_key = key if self.case_sensitive else key.upper()
            test_val = val if self.case_sensitive else [_.upper() for _ in val]
            if test_value == test_key or test_value in test_val:
                return key
        self.error(instance, value, extra='Not an available choice.')
762064
def _validate(self):
        
        errors = []
        for k in self._defaults.keys():
            try:
                validator = self._defaults[k]['validator']
                if validator is not None:
                    self[k] = validator(self[k])
            except ValueError as e:
                errors.append('\t{}: {}'.format(k, six.text_type(e)))

        if errors:
            raise ValueError(
                'Invalid configuration values were set: \n{}'.format('\n'.join(errors)))
418783
def validate(self):
        
        # Don't call the validator again, if it was already called for the
        # current input.
        if self.validation_state != ValidationState.UNKNOWN:
            return self.validation_state == ValidationState.VALID

        # Validate first. If not valid, set validation exception.
        if self.validator:
            try:
                self.validator.validate(self.document)
            except ValidationError as e:
                # Set cursor position (don't allow invalid values.)
                cursor_position = e.cursor_position
                self.cursor_position = min(max(0, cursor_position), len(self.text))

                self.validation_state = ValidationState.INVALID
                self.validation_error = e
                return False

        self.validation_state = ValidationState.VALID
        self.validation_error = None
        return True
323320
def validate_field(field, params)
      begin
        value = params.fetch(field)
        required_error(field) if value.nil? || value.empty?
      rescue KeyError
        required_error(field)
      end
    end
864257
def validate!
      errors.clear

      # Run the before_validate callbacks
      run_callbacks(:before_validate).then do
        # Run the actual validations
        run_validations
      end.then do
        # See if any server errors are in place and merge them in if they are
        errors.merge!(server_errors.to_h) if Volt.client?
      end.then do
        run_custom_validations
      end.then do
        # Return the errors object
        errors
      end
    end
717829
function validate( options ) {
		var validator,
			keys,
			key,
			err;

		if ( !isObject( options ) ) {
			return new TypeError( 'Stream()::invalid input argument. Options must be an object.' );
		}
		keys = Object.keys( options );
		for ( var i = 0; i < keys.length; i++ ) {
			key = keys[ i ];
			validator = validators[ key ];
			err = validator( options[key] );
			if ( err ) {
				return err;
			}
		}
	}
593431
def validate(self, data):
        """"""
        validated = self._validated(data)
        errors = []
        for validator in self.additional_validators:
            if not validator(validated):
                errors.append(
                    "%s invalidated by '%s'" % (
                        validated, _get_repr(validator)))
        if errors:
            raise NotValid(*errors)

        if self.default is UNSPECIFIED:
            return validated

        if self.null_values is not UNSPECIFIED\
                and validated in self.null_values:
            return self.default

        if validated is None:
            return self.default

        return validated
52065
def validate(self, value=None, model=None, context=None):
        
        errors = []
        for validator in self.validators:
            if value is None and not isinstance(validator, Required):
                continue

            error = validator.run(
                value=value,
                model=model,
                context=context if self.use_context else None
            )
            if error:
                errors.append(error)

        return errors
88893
def validate_input(dest, args)
      return true unless should_validate(dest)
      @input.each do |p|
        val = args[p[:symbol]]
      
        # if the argument has a value, no need to test whether it is optional.
        next unless !val || val == '*' || val == ''
      
        opts = p[:opts]
        unless opts[:optional]
          raise ArgumentError, "You must specify the required input #{p[:symbol]}"
        end
      end
      return true
    end
1230743
def validate(response)
      case response.code
        when 400; raise Error::BadRequest.new error_message(response)
        when 401; raise Error::Unauthorized.new error_message(response)
        when 403; raise Error::Forbidden.new error_message(response)
        when 404; raise Error::NotFound.new error_message(response)
        when 405; raise Error::MethodNotAllowed.new error_message(response)
        when 409; raise Error::Conflict.new error_message(response)
        when 500; raise Error::InternalServerError.new error_message(response)
        when 502; raise Error::BadGateway.new error_message(response)
        when 503; raise Error::ServiceUnavailable.new error_message(response)
      end

      response.parsed_response
    end
1308863
def validate(self, value):
        
        errors = []
        self._used_validator = []
        for val in self._validators:
            try:
                val.validate(value)
                self._used_validator.append(val)
            except ValidatorException as e:
                errors.append(e)
            except Exception as e:
                errors.append(ValidatorException("Unknown Error", e))
        if len(errors) > 0:
            raise ValidatorException.from_list(errors)
        return value
954902
def validate(self, data):
        
        autos, errors = [], []
        for s in [self._schema(s, error=self._error, ignore_extra_keys=self._ignore_extra_keys) for s in self._args]:
            try:
                validation = s.validate(data)
                self.match_count += 1
                if self.match_count > 1 and self.only_one:
                    break
                return validation
            except SchemaError as _x:
                autos, errors = _x.autos, _x.errors
        raise SchemaError(
            ["%r did not validate %r" % (self, data)] + autos,
            [self._error.format(data) if self._error else None] + errors,
        )
1035535
def each_item(*validators):
    
    def validate(value):
        for item in value:
            for validator in validators:
                error = validator(item)
                if error:
                    return error
        return None
    return validate
604707
def _validate(self, value):
        
        errors = []
        kwargs = {}
        for validator in self.validators:
            try:
                r = validator(value)
                if not isinstance(validator, Validator) and r is False:
                    self.fail('validator_failed')
            except ValidationError as err:
                kwargs.update(err.kwargs)
                if isinstance(err.messages, dict):
                    errors.append(err.messages)
                else:
                    errors.extend(err.messages)
        if errors:
            raise ValidationError(errors, **kwargs)
961546
def validate(self, value):
        
        try:
            # trap blank fields here
            if not self.blank or value:
                v = int(value)
                if v < 0:
                    return None
            return value
        except ValueError:
            return None
1211331
def _validate(self):
        
        errors = {}

        for name, validator in self._validators.items():
            value = getattr(self, name)

            try:
                validator(self, value)
            except ValidationError as e:
                errors[name] = str(e)

        self._validate_errors = errors