Raise a ValidationError if an address is not canonicalized.
18830
def validate_address(address: Any) -> None:
    
    if not is_address(address):
        raise ValidationError(f"Expected an address, got: {address}")
    if not is_canonical_address(address):
        raise ValidationError(
            "Py-EthPM library only accepts canonicalized addresses. "
            f"{address} is not in the accepted format."
        )
1152868
def _validate(self, inst: "InstanceNode", scope: ValidationScope,
                  ctype: ContentType) -> None:
        """"""
        if (scope.value & ValidationScope.syntax.value and
                inst.value not in self.type):
            raise YangTypeError(inst.json_pointer(), self.type.error_tag,
                                self.type.error_message)
        if (isinstance(self.type, LinkType) and        # referential integrity
                scope.value & ValidationScope.semantics.value and
                self.type.require_instance):
            try:
                tgt = inst._deref()
            except YangsonException:
                tgt = []
            if not tgt:
                raise SemanticError(inst.json_pointer(), "instance-required")
        super()._validate(inst, scope, ctype)
145494
def validate_or_raise(self, *a, **k):
        
        
        validate, err = self.validate(*a, **k)
        
        if err:
            raise ValidationException(err)
        
        return validate
61654
def validate_attributes
      unless address.present? || (lat.present? && lng.present?)
        raise ArgumentError, 'Must provide an address, or lat and lng.'
      end

      if address.present? && lat.present? && lng.present?
        raise ArgumentError, 'Cannot provide address, lat and lng.'
      end
    end
273053
def validate(self):
        """"""
        if not isinstance(self.fold_scope_location, FoldScopeLocation):
            raise TypeError(u'Expected FoldScopeLocation fold_scope_location, got: {} {}'.format(
                type(self.fold_scope_location), self.fold_scope_location))

        if self.fold_scope_location.field is None:
            raise ValueError(u'Expected FoldScopeLocation at a field, but got: {}'
                             .format(self.fold_scope_location))

        if self.fold_scope_location.field == COUNT_META_FIELD_NAME:
            if not GraphQLInt.is_same_type(self.field_type):
                raise TypeError(u'Expected the _x_count meta-field to be of GraphQLInt type, but '
                                u'encountered type {} instead: {}'
                                .format(self.field_type, self.fold_scope_location))
        else:
            if not isinstance(self.field_type, GraphQLList):
                raise ValueError(u'Invalid value of "field_type" for a field that is not '
                                 u'a meta-field, expected a list type but got: {} {}'
                                 .format(self.field_type, self.fold_scope_location))

            inner_type = strip_non_null_from_type(self.field_type.of_type)
            if isinstance(inner_type, GraphQLList):
                raise GraphQLCompilationError(
                    u'Outputting list-valued fields in a @fold context is currently not supported: '
                    u'{} {}'.format(self.fold_scope_location, self.field_type.of_type))
1046842
def _assert_valid_key(self, name):
    """"""
    if name not in self._measurements:
      raise NotAMeasurementError('Not a measurement', name, self._measurements)
213868
def _mask_invalid(self, data, header):
        """"""
        invalid = da.logical_or(data == header['block5']["count_value_outside_scan_pixels"][0],
                                data == header['block5']["count_value_error_pixels"][0])
        return da.where(invalid, np.float32(np.nan), data)
435189
def raise_error(self, message='', errors=None, field_name=None):
        
        field_name = field_name if field_name else self.field_name
        raise ValidationError(message, errors=errors, field_name=field_name)
809158
def _request_check(self, address):
        """"""
        server = self._servers.get(address)

        # "server" is None if another thread removed it from the topology.
        if server:
            server.request_check()
303731
def ValidateYesNoUnknown(value, column_name=None, problems=None):
  """"""
  if IsEmpty(value) or IsValidYesNoUnknown(value):
    return True
  else:
    if problems:
      problems.InvalidValue(column_name, value)
    return False
1052341
def validated_url(url):
    """"""
    try:
        u = urlparse(url)
        u.port  # Trigger 'invalid port' exception
    except Exception:
        raise error.URLError(url)
    else:
        if not u.scheme or not u.netloc:
            raise error.URLError(url)
        return url
32962
def raise_on_invalid_zip(func: Callable) -> Callable:
    """"""
    async def decorator(*args: list, **kwargs: dict) -> dict:
        """Decorate."""
        data = await func(*args, **kwargs)
        if not data['Location']['periods']:
            raise InvalidZipError('No data returned for ZIP code')
        return data

    return decorator
881440
def validate(self, obj):
        """"""
        if self.path:
            for i in self.path:
                obj = obj[i]
        obj = obj[self.field]

        raise NotImplementedError('Validation is not implemented yet')
68367
def validate(self):
        """"""
        try:
            for pkg in self.resolved_packages:
                pkg.validate_data()
        except RezError as e:
            raise ResolvedContextError("%s: %s" % (e.__class__.__name__, str(e)))
1035513
def validate(self, value):
        """"""
        try:
            self._choice = IPAddress(value)
            return True
        except (ValueError, AddrFormatError):
            self.error_message = '%s is not a valid IP address.' % value
            return False
969359
def validate(cls, data):
        """"""
        try:
            jsonschema.validate(
                data, cls.SCHEMA,
                # See: https://github.com/Julian/jsonschema/issues/148
                types={'array': (list, tuple)})
        except jsonschema.ValidationError as e:
            raise InvalidFormat("Failure data not of the"
                                " expected format: %s" % (e.message))
        else:
            # Ensure that all 'exc_type_names' originate from one of
            # base exceptions, because those are the root exceptions that
            # python mandates/provides and anything else is invalid...
            causes = collections.deque([data])
            while causes:
                cause = causes.popleft()
                try:
                    generated_on = cause['generated_on']
                    ok_bases = cls.BASE_EXCEPTIONS[generated_on[0]]
                except (KeyError, IndexError):
                    ok_bases = []
                root_exc_type = cause['exc_type_names'][-1]
                if root_exc_type not in ok_bases:
                    raise InvalidFormat(
                        "Failure data 'exc_type_names' must"
                        " have an initial exception type that is one"
                        " of %s types: '%s' is not one of those"
                        " types" % (ok_bases, root_exc_type))
                sub_cause = cause.get('cause')
                if sub_cause is not None:
                    causes.append(sub_cause)
646742
def validate(self):
        

        if not (self.recipients or self.cc or self.bcc):
            raise InvalidMessage("No recipients have been added")

        if not self.body and not self.html:
            raise InvalidMessage("No body has been set")

        if not self.sender:
            raise InvalidMessage("No sender address has been set")

        if self.is_bad_headers():
            raise BadHeaders