Method called by the validator object
to ask attribute to verify that the default it has (if any) is
valid for such type.
192025
@Override
    public void validateDefault(InputProblemReporter rep, boolean normalize)
        throws XMLStreamException
    {
        String normStr = validateDefaultName(rep, normalize);
        if (normalize) {
            mDefValue.setValue(normStr);
        }

        // Ok, but was it declared?

        /* 03-Dec-2004, TSa: This is rather ugly -- need to know we
         *   actually really get a DTD reader, and DTD reader needs
         *   to expose a special method... but it gets things done.
         */
        EntityDecl ent = ((MinimalDTDReader) rep).findEntity(normStr);
        checkEntity(rep, normStr, ent);
    }
340998
def validate(self):
        

        missing = self.missing_property_names()

        if len(missing) > 0:
            raise validators.ValidationError(
                "'{0}' are required attributes for {1}"
                            .format(missing, self.__class__.__name__))

        for prop, val in six.iteritems(self._properties):
            if val is None:
                continue

            if isinstance(val, ProtocolBase):
                val.validate()
            elif getattr(val, 'isLiteralClass', None) is True:
                val.validate()
            elif isinstance(val, list):
                for subval in val:
                  subval.validate()
            else:
                # This object is of the wrong type, but just try setting it
                # The property setter will enforce its correctness
                # and handily coerce its type at the same time
                setattr(self, prop, val)

        return True
30373
private Validator createDefaultValidator() {
        final ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
        final Validator validator = validatorFactory.usingContext()
                .getValidator();
        
        return validator;
    }
631190
def validate_required_attributes!
      unless required_attributes?
        blank_attribute = required_attributes.detect { |attr| self[attr].nil? || self[attr].empty? }

        raise ValidationError, "#{blank_attribute} can't be blank"
      end
    end
1225502
def validate(self, name, value):
        
        validator = self.attribute_validators.get(name, None)
        if validator:
            return True if validator(value) else False
        return True
973795
private void validateAttributes() {
    if (content == null) {
      throw new NullContentException("RendererBuilder needs content to create Renderer instances");
    }

    if (parent == null) {
      throw new NullParentException("RendererBuilder needs a parent to inflate Renderer instances");
    }

    if (layoutInflater == null) {
      throw new NullLayoutInflaterException(
          "RendererBuilder needs a LayoutInflater to inflate Renderer instances");
    }
  }
648049
private void validateAttributesToCreateANewRendererViewHolder() {
    if (viewType == null) {
      throw new NullContentException(
          "RendererBuilder needs a view type to create a RendererViewHolder");
    }
    if (layoutInflater == null) {
      throw new NullLayoutInflaterException(
          "RendererBuilder needs a LayoutInflater to create a RendererViewHolder");
    }
    if (parent == null) {
      throw new NullParentException(
          "RendererBuilder needs a parent to create a RendererViewHolder");
    }
  }
1146133
def _required_attribute(element, name, default):
    
    if element.get(name) is None:
        element.set(name, default)
621847
public static <T> T checkAndGet(T value, T defaultValue, Validator<T> v) {
		if (v.validate(value)) {
			return value;
		}

		return defaultValue;
	}
910084
private Validator getDefaultValidator(final FacesContext context) throws FacesException {
        if (!beanValidationPresent) {
            return null;
        }

        ValidatorFactory validatorFactory;
        Object cachedObject = context.getExternalContext().getApplicationMap().get(BeanValidator.VALIDATOR_FACTORY_KEY);
        if (cachedObject instanceof ValidatorFactory) {
            validatorFactory = (ValidatorFactory) cachedObject;
        } else {
            try {
                validatorFactory = Validation.buildDefaultValidatorFactory();
            } catch (ValidationException e) {
                throw new FacesException("Could not build a default Bean Validator factory", e);
            }
            context.getExternalContext().getApplicationMap().put(BeanValidator.VALIDATOR_FACTORY_KEY, validatorFactory);
        }
        return validatorFactory.getValidator();
    }
1082486
def check(cls, cfg, key_name, path, parent_cfg=None):
        

        attr = getattr(cls, key_name, None)

        if path != "":
            attr_full_name = "%s.%s" % (path, key_name)
        else:
            attr_full_name = key_name

        if not attr:
            # attribute specified by key_name is unknown, warn
            raise vodka.exceptions.ConfigErrorUnknown(attr_full_name)

        if attr.deprecated:
            vodka.log.warn("[config deprecated] %s is being deprecated in version %s" % (
                attr_full_name,
                attr.deprecated
            ))

        # prepare data
        for prepare in attr.prepare:
            cfg[key_name] = prepare(cfg[key_name])

        if hasattr(cls, "prepare_%s" % key_name):
            prepare = getattr(cls, "prepare_%s" % key_name)
            cfg[key_name] = prepare(cfg[key_name], config=cfg)

        value = cfg.get(key_name)

        if isinstance(attr.expected_type, types.FunctionType):
            # expected type holds a validator function
            p, reason = attr.expected_type(value)
            if not p:
                # validator did not pass
                raise vodka.exceptions.ConfigErrorValue(
                    attr_full_name,
                    attr,
                    value,
                    reason=reason
                )

        elif attr.expected_type != type(value):
            # attribute type mismatch
            raise vodka.exceptions.ConfigErrorType(
                attr_full_name,
                attr
            )

        if attr.choices and value not in attr.choices:
            # attribute value not valid according to
            # available choices
            raise vodka.exceptions.ConfigErrorValue(
                attr_full_name,
                attr,
                value
            )

        if hasattr(cls, "validate_%s" % key_name):
            # custom validator for this attribute was found
            validator = getattr(cls, "validate_%s" % key_name)
            valid, reason = validator(value)
            if not valid:
                # custom validator failed
                raise vodka.exceptions.ConfigErrorValue(
                    attr_full_name,
                    attr,
                    value,
                    reason=reason
                )

        num_crit = 0
        num_warn = 0


        if is_config_container(value) and attr.handler:
            if type(value) == dict or issubclass(type(value), Config):
                keys = list(value.keys())
            elif type(value) == list:
                keys = list(range(0, len(value)))
            else:
                return
            for k in keys:
                if not is_config_container(value[k]):
                    continue
                handler = attr.handler(k, value[k])
                if issubclass(handler, Handler):
                    h = handler
                else:
                    h = getattr(handler, "Configuration", None)

                #h = getattr(attr.handler(k, value[k]), "Configuration", None)
                if h:
                    if type(k) == int and type(value[k]) == dict and value[k].get("name"):
                        _path = "%s.%s" % (
                            attr_full_name, value[k].get("name"))
                    else:
                        _path = "%s.%s" % (attr_full_name, k)
                    _num_crit, _num_warn = h.validate(value[k], path=_path, nested=attr.nested, parent_cfg=cfg)
                    h.finalize(
                        value,
                        k,
                        value[k],
                        attr=attr,
                        attr_name=key_name,
                        parent_cfg=cfg
                    )
                    num_crit += _num_crit
                    num_warn += _num_warn

        attr.finalize(cfg, key_name, value, num_crit=num_crit)

        return (num_crit, num_warn)
593331
function _allFailingRequired(attributes) {
    for (var i in attributes) {
      var akey = attributes[i];

      if (resolvers.validateRequired(key, self._getValue(key))) {
        return false;
      }
    }

    return true;
  }
420185
def is_valid(self, attrs = None):
        
        if attrs is None:
            reason = {}
        else:
            reason = attrs
        valid = True
        for attr, validation in self.__class__.__validates__.items():
            if validation.__class__ == validators.validation:
                validation.name = attr
            if not validation(self):
                reason[attr] = getattr(self, attr)
                valid = False
        return valid
1144370
def validate(self, val):
        """"""
        if self.validation:
            self.type.validate(val)

            if self.custom_validator is not None:
                self.custom_validator(val)

        return True
1077210
def _validate_type(self, item, name):
        """"""
        if item is None:
            # don't validate None items, since they'll be caught by the portion
            # of the validator responsible for handling `required`ness
            return

        if not isinstance(item, self.allowed_types):
            item_class_name = item.__class__.__name__
            raise ArgumentError(name,
                "Expected one of %s, but got `%s`" % (
                    self.allowed_types, item_class_name))
820633
def _check_defaults(self, x_only=True):
		
		if self.x is None:
			self.err(self._check_defaults,
					 "X field is not set: please specify a parameter")
			return
		if x_only is True:
			return
		if self.y is None:
			self.err(self._check_defaults,
					 "Y field is not set: please specify a parameter")
			return
593539
def _check_or_set_default_params(self):
        """"""
        if not hasattr(self, 'date'):
            self._set_param('date', datetime.utcnow().strftime('%Y-%m-%d'))
        if not hasattr(self, 'version'):
            self._set_param('version', self.default_version)
        # pylint: disable=no-member
        if not hasattr(self, 'description') or self.description is None:
            getattr(self, '_set_param')('description', self.warning_message)