Validates a given value against the schema and configured validation rules.

        :param path: a dot notation path to the value.

        :param value: a value to be validated.

        :param results: a list with validation results to add new results.
559468
def _perform_validation(self, path, value, results):
        
        path = self.name if path == None or len(path) == 0 else path + "." + self.name

        super(PropertySchema, self)._perform_validation(path, value, results)
        self._perform_type_validation(path, self.value_type, value, results)
783957
def _validate_number(self, input_number, path_to_root, object_title=''):

        '''
            
        '''

        rules_path_to_root = re.sub('\[\d+\]', '[0]', path_to_root)
        input_criteria = self.keyMap[rules_path_to_root]
        error_dict = {
            'object_title': object_title,
            'model_schema': self.schema,
            'input_criteria': input_criteria,
            'failed_test': 'value_datatype',
            'input_path': path_to_root,
            'error_value': input_number,
            'error_code': 4001
        }
        if 'integer_data' in input_criteria.keys():
            if input_criteria['integer_data'] and not isinstance(input_number, int):
                error_dict['failed_test'] = 'integer_data'
                error_dict['error_code'] = 4021
                raise InputValidationError(error_dict)
        if 'min_value' in input_criteria.keys():
            if input_number < input_criteria['min_value']:
                error_dict['failed_test'] = 'min_value'
                error_dict['error_code'] = 4022
                raise InputValidationError(error_dict)
        if 'max_value' in input_criteria.keys():
            if input_number > input_criteria['max_value']:
                error_dict['failed_test'] = 'max_value'
                error_dict['error_code'] = 4023
                raise InputValidationError(error_dict)
        if 'greater_than' in input_criteria.keys():
            if input_number <= input_criteria['greater_than']:
                error_dict['failed_test'] = 'greater_than'
                error_dict['error_code'] = 4024
                raise InputValidationError(error_dict)
        if 'less_than' in input_criteria.keys():
            if input_number >= input_criteria['less_than']:
                error_dict['failed_test'] = 'less_than'
                error_dict['error_code'] = 4025
                raise InputValidationError(error_dict)
        if 'equal_to' in input_criteria.keys():
            if input_number != input_criteria['equal_to']:
                error_dict['failed_test'] = 'equal_to'
                error_dict['error_code'] = 4026
                raise InputValidationError(error_dict)
        if 'discrete_values' in input_criteria.keys():
            if input_number not in input_criteria['discrete_values']:
                error_dict['failed_test'] = 'discrete_values'
                error_dict['error_code'] = 4041
                raise InputValidationError(error_dict)
        if 'excluded_values' in input_criteria.keys():
            if input_number in input_criteria['excluded_values']:
                error_dict['failed_test'] = 'excluded_values'
                error_dict['error_code'] = 4042
                raise InputValidationError(error_dict)

    # TODO: validate number against identical to reference

    # TODO: run lambda function and call validation url

        return input_number
553948
def valid(self, value, level=[]):
		

		# Reset validation failures
		self.validation_failures = []

		# If the value is None and it's optional, we're good
		if value is None and self._optional:
			return True

		# If the value isn't a dictionary
		if not isinstance(value, dict):
			self.validation_failures.append(('.'.join(level), str(value)))
			return False

		# Init the return, assume valid
		bRet = True

		# Go through each key and value
		for k,v in iteritems(value):

			# Add the field to the level
			lLevel = level[:]
			lLevel.append(k)

			# If the key isn't valid
			if not self._key.valid(k):
				self.validation_failures.append(('.'.join(lLevel), 'invalid key: %s' % str(k)))
				bRet = False
				continue

			# Check the value
			if not self._node.valid(v, lLevel):
				self.validation_failures.extend(self._node.validation_failures)
				bRet = False
				continue

		# Return whatever the result was
		return bRet
177584
def validate(self, value):
        
        if value in self.empty_values and self.required:
            raise ValidationError(self.error_messages['required'])
311227
def validate(data):
        
        try:
            return Schema(Validator.SCHEMA).validate(data)
        except SchemaError as exception:
            logging.getLogger(__name__).error(exception)
            return None
1345573
def _validate_boolean(self, input_boolean, path_to_root, object_title=''):

        '''
            
        '''

        rules_path_to_root = re.sub('\[\d+\]', '[0]', path_to_root)
        input_criteria = self.keyMap[rules_path_to_root]
        error_dict = {
            'object_title': object_title,
            'model_schema': self.schema,
            'input_criteria': input_criteria,
            'failed_test': 'value_datatype',
            'input_path': path_to_root,
            'error_value': input_boolean,
            'error_code': 4001
        }
        if 'equal_to' in input_criteria.keys():
            if input_boolean != input_criteria['equal_to']:
                error_dict['failed_test'] = 'equal_to'
                error_dict['error_code'] = 4026
                raise InputValidationError(error_dict)

    # TODO: validate boolean against identical to reference

    # TODO: run lambda function and call validation url

        return input_boolean
1133008
def _perform_validation(self, path, value, results):
        
        name = path if path != None else "value"
        value = ObjectReader.get_value(value)

        super(MapSchema, self)._perform_validation(path, value, results)

        if value == None:
            return

        if isinstance(value, dict):
            for (key, value) in value.items():
                element_path = key if path == None or len(path) == 0 else path + "." + key

                self._perform_type_validation(element_path, self.key_type, key, results)
                self._perform_type_validation(element_path, self.value_type, value, results)
        else:
            results.append(
                ValidationResult(
                    path,
                    ValidationResultType.Error,
                    "VALUE_ISNOT_MAP",
                    name + " type is expected to be Map",
                    "Map",
                    type(value)
                )
            )
812437
def validate(self, data, schema):
        '''
        '''
        try:
            return schema(data)
        except MultipleInvalid as ie:
            errors = []
            for error in ie.errors:
                if error.path:
                    field = '.'.join(str(p) for p in error.path)
                    path = error.path
                    value = data
                    while path:
                        attr = path.pop(0)
                        try:
                            if isinstance(value, (list, tuple)):
                                attr = int(attr)
                            value = value[attr]
                        except Exception:
                            value = None

                    txt = safe_unicode(error).replace('for dictionary value', '')
                    txt = txt.strip()
                    if isinstance(error, RequiredFieldInvalid):
                        msg = '[{0}] {1}'
                    else:
                        msg = '[{0}] {1}: {2}'
                    try:
                        msg = msg.format(field, txt, str(value))
                    except Exception:
                        msg = '[{0}] {1}'.format(field, txt)

                else:
                    msg = str(error)
                errors.append(msg)
            msg = '\n- '.join(['Validation error:'] + errors)
            raise HarvestValidationError(msg)
1205904
def validate(self, value, add_comments=False, schema_name="map"):
        
        validator = self.get_schema_validator(schema_name)

        error_messages = []

        if isinstance(value, list):
            for d in value:
                error_messages += self._validate(d, validator, add_comments, schema_name)
        else:
            error_messages = self._validate(value, validator, add_comments, schema_name)

        return error_messages
560869
def _validate_path(path):
  
  if not path:
    raise ValueError('Path is empty')
  if not isinstance(path, basestring):
    raise TypeError('Path should be a string but is %s (%s).' %
                    (path.__class__, path))
788973
public List<ValidationResult> validate(Object value) {
		List<ValidationResult> results = new ArrayList<ValidationResult>();
		performValidation("", value, results);
		return results;
	}
45040
def validate(self, value, param_name, exc=None, logger=None):
        
        if exc is not None:
            self.exc = exc

        if logger is not None:
            self.logger = logger

        if self.type is not None and not type(value) == self.type:  # pylint: disable=unidiomatic-typecheck
            self.error(
                f'invalid type for parameter "{param_name}": {type(value)} (value: {value}) -- expected {self.type}'
            )

        if self.instance is not None and not isinstance(value, self.instance):
            self.error(
                f'invalid instance for parameter "{param_name}": {type(value)} (value: {value})'
                f' -- expected {self.instance}'
            )

        if self.min is not None and value < self.min:
            self.error(f'invalid value for parameter "{param_name}" (under minima of {self.min}): {value}')

        if self.max is not None and value > self.max:
            self.error(f'invalid value for parameter "{param_name}" (over maxima if {self.max}): {value}')

        if self.regex is not None and not re_full_match(self.regex, value):
            self.error(f'invalid value for parameter "{param_name}" (should match: "{self.regex}"): {value}')

        if self.in_list is not None and value not in self.in_list:
            self.error(f'invalid value for parameter "{param_name}"; "{value}" is not in list: {self.in_list}')

        if self.path_exists and not exists(value):
            self.error(f'"{param_name}" file does not exist: {value}')

        return True
1181610
def _validate_keyschema(self, schema, field, value):
        
        if isinstance(value, Mapping):
            validator = self._get_child_validator(
                document_crumb=field,
                schema_crumb=(field, 'keyschema'),
                schema=dict(((k, schema) for k in value.keys())))
            if not validator(dict(((k, k) for k in value.keys())),
                             normalize=False):
                self._drop_nodes_from_errorpaths(validator._errors,
                                                 [], [2, 4])
                self._error(field, errors.KEYSCHEMA, validator._errors)
691087
def _validate_items(self, path, obj, _):
        
        errs = []

        if obj.type == 'void':
            errs.append('void is only allowed in Operation object.')

        return path, obj.__class__.__name__, errs
1250610
def validate(self, value):
        
        if not self._compiled_regex.match(value):
            raise ValidationError(
                'value {:s} not match r"{:s}"'.format(value, self._regex))
157796
def choose
      validate_path
      search_paths_list = search_paths
      if search_paths_list.empty?
        puts "\nThere is no /schema[^\/]*.rb$/ in the directory #{@path}"
        exit
      end

      search_paths_list.each_with_index {|path,indx|  puts "#{indx}. #{path}" }

      begin
        print "\nSelect a path to the target schema: "
      end while search_paths_list[(id = STDIN.gets.to_i)].nil?

      search_paths_list[id]
    end
83709
def valid(self, value, level=[]):
		

		# Reset validation failures
		self.validation_failures = []

		# If the value is None and it's optional, we're good
		if value is None and self._optional:
			return True

		# If the value isn't a list
		if not isinstance(value, list):
			self.validation_failures.append(('.'.join(level), str(value)))
			return False

		# Init the return, assume valid
		bRet = True

		# Keep track of duplicates
		if self._type == 'unique':
			lItems	= []

		# Go through each item in the list
		for i in range(len(value)):

			# Add the field to the level
			lLevel = level[:]
			lLevel.append('[%d]' % i)

			# If the element isn't valid, return false
			if not self._node.valid(value[i], lLevel):
				self.validation_failures.extend(self._node.validation_failures[:])
				bRet = False;
				continue;

			# If we need to check for duplicates
			if self._type == 'unique':

				# Try to get an existing item
				try:

					# If it is found, we have a duplicate
					iIndex = lItems.index(value[i])

					# Add the error to the list
					self.validation_failures.append(('.'.join(lLevel), 'duplicate of %s[%d]' % ('.'.join(level), iIndex)))
					bRet = False
					continue

				# If a Value Error is thrown, there is no duplicate, add the
				# 	value to the list and continue
				except ValueError:
					lItems.append(value[i])

		# If there's a minumum
		if self._minimum is not None:

			# If we don't have enough
			if len(value) < self._minimum:
				self.validation_failures.append(('.'.join(level), 'did not meet minimum'))
				bRet = False

		# If there's a maximum
		if self._maximum is not None:

			# If we have too many
			if len(value) > self._maximum:
				self.validation_failures.append(('.'.join(level), 'exceeds maximum'))
				bRet = False

		# Return whatever the result was
		return bRet