Check if the formats of principals and actions are valid.

        :return: True, if the policy is valid
        :raises: InvalidApplicationPolicyError
558562
def validate(self):
        
        if not self.principals:
            raise InvalidApplicationPolicyError(error_message='principals not provided')

        if not self.actions:
            raise InvalidApplicationPolicyError(error_message='actions not provided')

        if any(not self._PRINCIPAL_PATTERN.match(p) for p in self.principals):
            raise InvalidApplicationPolicyError(
                error_message='principal should be 12-digit AWS account ID or "*"')

        unsupported_actions = sorted(set(self.actions) - set(self.SUPPORTED_ACTIONS))
        if unsupported_actions:
            raise InvalidApplicationPolicyError(
                error_message='{} not supported'.format(', '.join(unsupported_actions)))

        return True
22486
def _get_final_none_policy_for_validator(is_nonable,   # type: bool
                                         none_policy   # type: NoneArgPolicy
                                         ):
    
    if none_policy in {NonePolicy.VALIDATE, NonePolicy.SKIP, NonePolicy.FAIL}:
        none_policy_to_use = none_policy

    elif none_policy is NoneArgPolicy.SKIP_IF_NONABLE_ELSE_VALIDATE:
        none_policy_to_use = NonePolicy.SKIP if is_nonable else NonePolicy.VALIDATE

    elif none_policy is NoneArgPolicy.SKIP_IF_NONABLE_ELSE_FAIL:
        none_policy_to_use = NonePolicy.SKIP if is_nonable else NonePolicy.FAIL

    else:
        raise ValueError('Invalid none policy: ' + str(none_policy))
    return none_policy_to_use
693423
def is_valid(self, qstr=None):
        """"""
        if qstr is None:
            qstr = self.currentText()
        return osp.isdir(to_text_string(qstr))
1218468
def _is_policy_template(self, policy):
        

        return self._policy_template_processor is not None and \
            isinstance(policy, dict) and \
            len(policy) == 1 and \
            self._policy_template_processor.has(list(policy.keys())[0]) is True
593308
def is_valid(self):
        
        conditions = [
            self.protocol_id == 0,  # Modbus always uses protocol 0
            2 <= self.length <= 260,  # Absolute length limits
            len(self.data) == self.length - 2,  # Total length matches data length
        ]
        return all(conditions)
855112
def is_valid(self):
        
        if not self.text:
            return False

        try:
            pysrt.from_string(self.text, error_handling=pysrt.ERROR_RAISE)
        except pysrt.Error as e:
            if e.args[0] < 80:
                return False

        return True
1334134
def check_valid(self, get_params):
        
        if self.commands._if:
            return self.commands._if.check_valid(get_params)
819594
def is_valid(self):
        
        for spec in self.product_specs:

            for feature in spec.get('mandatory', []):
                if feature.replace('__', '.') not in self.feature_list:
                    self.errors_mandatory.append(feature)

            for feature in spec.get('never', []):
                if feature.replace('__', '.') in self.feature_list:
                    self.errors_never.append(feature)

        return not self.has_errors()
1295088
def get_valid_actions(self) -> List[Dict[str, Tuple[torch.Tensor, torch.Tensor, List[int]]]]:
        
        return [state.get_valid_actions() for state in self.grammar_state]
1158528
def is_valid(self):
        ''''''
        return (self.is_primitive and self.name) \
            or (self.is_complex and self.name) \
            or (self.is_list and self.nested) \
            or (self.is_map and self.nested) \
            or (self.is_model and self.nested)
818167
def assert_valid(self):
        """"""

        for ns_uri, ni in six.iteritems(self.__ns_uri_map):
            if not ni.uri:
                raise InvalidNamespaceSetError(
                    "URI not set in _NamespaceInfo (id={0}):\n{1}".format(
                        id(ni), ni
                    )
                )

            if ns_uri != ni.uri:
                raise InvalidNamespaceSetError(
                    "URI mismatch in dict ({0}) and _NamespaceInfo ({1})".format(
                        ns_uri, ni.uri
                    )
                )

            if (ni.preferred_prefix is not None and
               ni.preferred_prefix not in ni.prefixes):
                raise InvalidNamespaceSetError(
                    "Namespace {0.uri}: preferred prefix " \
                    '"{0.preferred_prefix}" not in prefixes ' \
                    "{0.prefixes}".format(ni)
                )

            for prefix in ni.prefixes:
                if not prefix:
                    raise InvalidNamespaceSetError(
                        "Namespace {0.uri}: empty value in prefix " \
                        "set: {0.prefixes}".format(ni)
                    )
                other_ni = self.__prefix_map.get(prefix)
                if other_ni is None:
                    raise InvalidNamespaceSetError(
                        'Namespace {0.uri}: prefix "{1}" not in ' \
                        'prefix map'.format(ni, prefix)
                    )
                if other_ni is not ni:
                    raise InvalidNamespaceSetError(
                        'Namespace {0.uri}: prefix "{1}" maps to ' \
                        'wrong _NamespaceInfo (id={2}, uri={3.uri})'.format(
                            ni, prefix, id(other_ni), other_ni
                        )
                    )

        if None in self.__prefix_map:
            # None can be a preferred prefix, but should not be in the
            # prefix map.
            raise InvalidNamespaceSetError("None is in prefix map!")
469149
def valid(self):
        
        return True if self.webdav.valid() and self.proxy.valid() else False
641907
def isvalid(self):
        

        gcontents = [gf.rstrip('\n') for gf in self.repo.bake('ls-files')()]
        fcontents = os.listdir(self.repopath)
        return all([sf in gcontents for sf in std_files]) and all([sf in fcontents for sf in std_files])
1074172
def is_valid(self, name=None, debug=False):
        
        valid_tags = self.action_tree
        invalid = False
        for item in self.current_tree:
            try:
                if item in valid_tags or self.ALL_TAGS in valid_tags:
                    valid_tags = valid_tags[item if item in valid_tags else self.ALL_TAGS]
                else:
                    valid_tags = None
                    invalid = True
                    break
            except (KeyError, TypeError) as e:  # object is either missing the key or is not a dictionary type
                invalid = True
                break
        if debug:
            print name, not invalid and valid_tags is not None
        return not invalid and valid_tags is not None
825233
def is_valid(self):
        '''
        
        '''

        valid = super(RegistrationContactForm,self).is_valid()
        msgs = messages.get_messages(self._request)

        # We only want validation messages to show up once, so pop messages that have already show up
        # before checking to see if any messages remain to be shown.
        prior_messages = self._session.pop('prior_messages',[])
        remaining_messages = []

        for m in msgs:
            m_dict = {'message': m.message, 'level': m.level, 'extra_tags': m.extra_tags}
            if m_dict not in prior_messages:
                remaining_messages.append(m_dict)

        if remaining_messages:
            self._session['prior_messages'] = remaining_messages
            self._request.session.modified = True
            return False
        return valid
913457
def is_valid_for(self, entry_point, protocol):
        """"""
        return self.available_for_entry_point(entry_point) and self.available_for_protocol(protocol)
850017
def valid(self):
        """"""

        now = timezone.now()
        return self.filter(revoked=False, expires__gt=now, valid_from__lt=now)