code
stringlengths
1
18.2k
generate_nonce_timestamp() engine.start(nonce=nonce) return nonce + engine.finish(chunk) else: nonce = chunk[:__nonce_length__] encryptedchunk = chunk[__nonce_length__:__nonce_length__ + __gcmtag_length__ + __chunk_size__] engine.start(nonce=nonce) decryptedchunk = engine.finish(encryptedchunk) if decryptedchunk == b""...
def retrieve_info(self): """Query Bugzilla API to retrieve the needed infos.""" scheme = urlparse(self.url).scheme netloc = urlparse(self.url).netloc query = urlparse(self.url).query if scheme not in ('http', 'https'): return for item in query.split('&'): if 'id=' in item: ticket_id = item.split('=')[1] break else: ret...
self.issue_id = tree.findall("./bug/bug_id").pop().text self.reporter = tree.findall("./bug/reporter").pop().text self.assignee = tree.findall("./bug/assigned_to").pop().text self.status = tree.findall("./bug/bug_status").pop().text self.product = tree.findall("./bug/product").pop().text self.component = tree.findall("...
pass
def minlen(min_length, strict=False # type: bool ): """ 'Minimum length' validation_function generator. Returns a validation_function to check that len(x) >= min_length (strict=False, default) or len(x) > min_length (strict=True) :param min_length: minimum length for x :param strict: Boolean flag to switch between len(...
raise Failure('minlen: len(x) > ' + str(min_length) + ' does not hold for x=' + str(x)) raise TooShort(wrong_value=x, min_length=min_length, strict=True) else: def minlen_(x): if len(x) >= min_length: return True else: # raise Failure('minlen: len(x) >= ' + str(min_length) + ' does not hold for x=' + str(x)) raise TooS...
def maxlen(max_length, strict=False # type: bool ): """ 'Maximum length' validation_function generator. Returns a validation_function to check that len(x) <= max_length (strict=False, default) or len(x) < max_length (strict=True) :param max_length: maximum length for x :param strict: Boolean flag to switch between len(...
raise Failure('maxlen: len(x) < ' + str(max_length) + ' does not hold for x=' + str(x)) raise TooLong(wrong_value=x, max_length=max_length, strict=True) else: def maxlen_(x): if len(x) <= max_length: return True else: # raise Failure('maxlen: len(x) <= ' + str(max_length) + ' does not hold for x=' + str(x)) raise TooLo...
def has_length(ref_length): """ 'length equals' validation function generator. Returns a validation_function to check that `len(x) == ref_length` :param ref_length: :return: """ def has_length_(x): if len(x) == ref_length: return True else: raise WrongLength(wrong_value=x, ref_length=ref_length) has_length_.__name__ = ...
def length_between(min_len, max_len, open_left=False, # type: bool open_right=False # type: bool ): """ 'Is length between' validation_function generator. Returns a validation_function to check that `min_len <= len(x) <= max_len (default)`. `open_right` and `open_left` flags allow to transform each side into strict mod...
x :param open_left: Boolean flag to turn the left inequality to strict mode :param open_right: Boolean flag to turn the right inequality to strict mode :return: """ if open_left and open_right: def length_between_(x): if (min_len < len(x)) and (len(x) < max_len): return True else: # raise Failure('length between: {} < ...
left_strict=True, max_length=max_len, right_strict=True) elif open_left: def length_between_(x): if (min_len < len(x)) and (len(x) <= max_len): return True else: # raise Failure('length between: {} < len(x) <= {} does not hold for x={}'.format(min_len, max_len, # x)) raise LengthNotInRange(wrong_value=x, min_length=min...
{} does not hold for x={}'.format(min_len, max_len, # x)) raise LengthNotInRange(wrong_value=x, min_length=min_len, left_strict=False, max_length=max_len, right_strict=True) else: def length_between_(x): if (min_len <= len(x)) and (len(x) <= max_len): return True else: # raise Failure('length between: {} <= len(x) <= {...
def is_in(allowed_values # type: Set ): """ 'Values in' validation_function generator. Returns a validation_function to check that x is in the provided set of allowed values :param allowed_values: a set of allowed values :return: """ def is_in_allowed_values(x): if x in allowed_values: return True else: # raise Failure...
is_in_allowed_values.__name__ = 'is_in_{}'.format(allowed_values) return is_in_allowed_values
def is_subset(reference_set # type: Set ): """ 'Is subset' validation_function generator. Returns a validation_function to check that x is a subset of reference_set :param reference_set: the reference set :return: """ def is_subset_of(x): missing = x - reference_set if len(missing) == 0: return True else: # raise Failu...
+ str(reference_set) + '. x contains unsupported ' # 'elements ' + str(missing)) raise NotSubset(wrong_value=x, reference_set=reference_set, unsupported=missing) is_subset_of.__name__ = 'is_subset_of_{}'.format(reference_set) return is_subset_of
def contains(ref_value): """ 'Contains' validation_function generator. Returns a validation_function to check that `ref_value in x` :param ref_value: a value that must be present in x :return: """ def contains_ref_value(x): if ref_value in x: return True else: raise DoesNotContainValue(wrong_value=x, ref_value=ref_valu...
def is_superset(reference_set # type: Set ): """ 'Is superset' validation_function generator. Returns a validation_function to check that x is a superset of reference_set :param reference_set: the reference set :return: """ def is_superset_of(x): missing = reference_set - x if len(missing) == 0: return True else: # rai...
+ str(reference_set) + '. x does not contain required ' # 'elements ' + str(missing)) raise NotSuperset(wrong_value=x, reference_set=reference_set, missing=missing) is_superset_of.__name__ = 'is_superset_of_{}'.format(reference_set) return is_superset_of
def on_all_(*validation_func): """ Generates a validation_function for collection inputs where each element of the input will be validated against the validation_functions provided. For convenience, a list of validation_functions can be provided and will be replaced with an 'and_'. Note that if you want to apply DIFFER...
or list of base validation functions to use. A callable, a tuple(callable, help_msg_str), a tuple(callable, failure_type), or a list of several such elements. Nested lists are supported and indicate an implicit `and_` (such as the main list). Tuples indicate an implicit `_failure_raiser`. [mini_lambda](https://smarie.g...
validation_function_func = _process_validation_function_s(list(validation_func)) def on_all_val(x): # validate all elements in x in turn for idx, x_elt in enumerate(x): try: res = validation_function_func(x_elt) except Exception as e: raise InvalidItemInSequence(wrong_value=x_elt, wrapped_func=validation_function_func,...
str(x_elt)) raise InvalidItemInSequence(wrong_value=x_elt, wrapped_func=validation_function_func, validation_outcome=res) return True on_all_val.__name__ = 'apply_<{}>_on_all_elts'.format(get_callable_name(validation_function_func)) return on_all_val
def on_each_(*validation_functions_collection): """ Generates a validation_function for collection inputs where each element of the input will be validated against the corresponding validation_function(s) in the validation_functions_collection. Validators inside the tuple can be provided as a list for convenience, this...
all elements in the input, you should rather use on_all_. :param validation_functions_collection: a sequence of (base validation function or list of base validation functions to use). A base validation function may be a callable, a tuple(callable, help_msg_str), a tuple(callable, failure_type), or a list of several suc...
implicit `_failure_raiser`. [mini_lambda](https://smarie.github.io/python-mini-lambda/) expressions can be used instead of callables, they will be transformed to functions automatically. :return: """ # create a tuple of validation functions. validation_function_funcs = tuple(_process_validation_function_s(validation_fu...
of elements than validation_functions_collection.') else: # apply each validation_function on the input with the same position in the collection idx = -1 for elt, validation_function_func in zip(x, validation_function_funcs): idx += 1 try: res = validation_function_func(elt) except Exception as e: raise InvalidItemInSe...
# + '] (' + str(validation_functions_collection[idx]) + ') failed validation for ' # 'input ' + str(x[idx])) raise InvalidItemInSequence(wrong_value=elt, wrapped_func=validation_function_func, validation_outcome=res) return True on_each_val.__name__ = 'map_<{}>_on_elts' \ ''.format('(' + ', '.join([get_callable_name(f)...
def get_jobs_events_from_sequence(user, sequence): """Get all the jobs events from a given sequence number.""" args = schemas.args(flask.request.args.to_dict()) if user.is_not_super_admin(): raise dci_exc.Unauthorized() query = sql.select([models.JOBS_EVENTS]). \ select_from(models.JOBS_EVENTS.join(models.JOBS, models....
rows, '_meta': {'count': nb_rows}})
def from_file(cls, f): """ Constructs a :class:`~mwxml.iteration.dump.Dump` from a `file` pointer. :Parameters: f : `file` A plain text file pointer containing XML to process """ element = ElementIterator.from_file(f) assert element.tag == "mediawiki" return cls.from_element(element)
def from_page_xml(cls, page_xml): """ Constructs a :class:`~mwxml.iteration.dump.Dump` from a <page> block. :Parameters: page_xml : `str` | `file` Either a plain string or a file containing <page> block XML to process """ header = """ <mediawiki xmlns="http://www.mediawiki.org/xml/export-0.5/" xmlns:xsi="http://www.w3....
def calc_derivation(passphrase, salt): """ Calculate a 32 bytes key derivation with Argon2. :param passphrase: A string of any length specified by user. :param salt: 512 bits generated by Botan Random Number Generator. :return: a 32 bytes keys. """ argonhash = argon2.low_level.hash_secret_raw((str.encode(passphrase)), ...
def get_node_text(self, node): """ Return contatenated value of all text node children of this element """ text_children = [n.nodeValue for n in self.get_node_children(node) if n.nodeType == xml.dom.Node.TEXT_NODE] if text_children: return u''.join(text_children) else: return None
def set_node_text(self, node, text): """ Set text value as sole Text child node of element; any existing Text nodes are removed """ # Remove any existing Text node children for child in self.get_node_children(node): if child.nodeType == xml.dom.Node.TEXT_NODE: self.remove_node_child(node, child, True) if text is not No...
def _get_contents(self): """Create strings from glob strings.""" def files(): for value in super(GlobBundle, self)._get_contents(): for path in glob.glob(value): yield path return list(files())
def is_generic_type(tp): """Test if the given type is a generic type. This includes Generic itself, but excludes special typing constructs such as Union, Tuple, Callable, ClassVar. Examples:: is_generic_type(int) == False is_generic_type(Union[int, str]) == False is_generic_type(Union[int, T]) == False is_generic_type(...
True """ if NEW_TYPING: return (isinstance(tp, type) and issubclass(tp, Generic) or isinstance(tp, _GenericAlias) and tp.__origin__ not in (Union, tuple, ClassVar, collections.abc.Callable)) # SMA: refering to is_callable_type and is_tuple_type to avoid duplicate code return isinstance(tp, GenericMeta) and not is_calla...
def is_union_type(tp): """Test if the type is a union type. Examples:: is_union_type(int) == False is_union_type(Union) == True is_union_type(Union[int, int]) == False is_union_type(Union[T, int]) == True """ if NEW_TYPING: return (tp is Union or isinstance(tp, _GenericAlias) and tp.__origin__ is Union) try: from typin...
type(tp) is type(Union)
def is_classvar(tp): """Test if the type represents a class variable. Examples:: is_classvar(int) == False is_classvar(ClassVar) == True is_classvar(ClassVar[int]) == True is_classvar(ClassVar[List[T]]) == True """ if NEW_TYPING: return (tp is ClassVar or isinstance(tp, _GenericAlias) and tp.__origin__ is ClassVar) try...
def parse(to_parse, ignore_whitespace_text_nodes=True, adapter=None): """ Parse an XML document into an *xml4h*-wrapped DOM representation using an underlying XML library implementation. :param to_parse: an XML document file, document string, or the path to an XML file. If a string value is given that contains a ``<`` ...
to_parse: a file-like object or string :param bool ignore_whitespace_text_nodes: if ``True`` pure whitespace nodes are stripped from the parsed document, since these are usually noise introduced by XML docs serialized to be human-friendly. :param adapter: the *xml4h* implementation adapter class used to parse the docum...
:return: an :class:`xml4h.nodes.Document` node representing the parsed document. Delegates to an adapter's :meth:`~xml4h.impls.interface.parse_string` or :meth:`~xml4h.impls.interface.parse_file` implementation. """ if adapter is None: adapter = best_adapter if isinstance(to_parse, basestring) and '<' in to_parse: retu...
def build(tagname_or_element, ns_uri=None, adapter=None): """ Return a :class:`~xml4h.builder.Builder` that represents an element in a new or existing XML DOM and provides "chainable" methods focussed specifically on adding XML content. :param tagname_or_element: a string name for the root node of a new XML document, o...
to the new root node. This argument has no effect this method is acting on an element. :type ns_uri: string or None :param adapter: the *xml4h* implementation adapter class used to interact with the document DOM nodes. If None, :attr:`best_adapter` will be used. :type adapter: adapter class or None :return: a :class:`~...
adapter is None: adapter = best_adapter if isinstance(tagname_or_element, basestring): doc = adapter.create_document( tagname_or_element, ns_uri=ns_uri) element = doc.root elif isinstance(tagname_or_element, xml4h.nodes.Element): element = tagname_or_element else: raise xml4h.exceptions.IncorrectArgumentTypeException( ...
def get_none_policy_text(none_policy, # type: int verbose=False # type: bool ): """ Returns a user-friendly description of a NonePolicy taking into account NoneArgPolicy :param none_policy: :param verbose: :return: """ if none_policy is NonePolicy.SKIP: return "accept None without performing validation" if verbose else...
as any other values" if verbose else 'VALIDATE' elif none_policy is NoneArgPolicy.SKIP_IF_NONABLE_ELSE_FAIL: return "accept None without validation if the argument is optional, otherwise fail on None" if verbose \ else 'SKIP_IF_NONABLE_ELSE_FAIL' elif none_policy is NoneArgPolicy.SKIP_IF_NONABLE_ELSE_VALIDATE: return "...
str(none_policy))
def _add_none_handler(validation_callable, # type: Callable none_policy # type: int ): # type: (...) -> Callable """ Adds a wrapper or nothing around the provided validation_callable, depending on the selected policy :param validation_callable: :param none_policy: an int representing the None policy, see NonePolicy :re...
None values elif none_policy is NonePolicy.VALIDATE: return validation_callable # do not handle None specifically, do not wrap else: raise ValueError('Invalid none_policy : ' + str(none_policy))
def add_base_type_dynamically(error_type, additional_type): """ Utility method to create a new type dynamically, inheriting from both error_type (first) and additional_type (second). The class representation (repr(cls)) of the resulting class reflects this by displaying both names (fully qualified for the first type, _...
dynamically, with the same name class new_error_type(with_metaclass(MetaReprForValidator, error_type, additional_type, object)): pass new_error_type.__name__ = error_type.__name__ + '[' + additional_type.__name__ + ']' if sys.version_info >= (3, 0): new_error_type.__qualname__ = error_type.__qualname__ + '[' + addition...
def assert_valid(name, # type: str value, # type: Any *validation_func, # type: ValidationFuncs **kwargs): """ Validates value `value` using validation function(s) `base_validator_s`. As opposed to `is_valid`, this function raises a `ValidationError` if validation fails. It is therefore designed to be used for defensiv...
is a friendly alias for `_validator(base_validator_s)(value)` :param validation_func: the base validation function or list of base validation functions to use. A callable, a tuple(callable, help_msg_str), a tuple(callable, failure_type), or a list of several such elements. Nested lists are supported and indicate an imp...
be transformed to functions automatically. :param name: the name of the variable to validate. It will be used in error messages :param value: the value to validate :param none_policy: describes how None values should be handled. See `NonePolicy` for the various possibilities. Default is `NonePolicy.VALIDATE`, meaning t...
a subclass of ValidationError to raise in case of validation failure. By default a ValidationError will be raised with the provided help_msg :param help_msg: an optional help message to be used in the raised error in case of validation failure. :param kw_context_args: optional keyword arguments providing additional con...
of success. In case of failure, raises a <error_type> if provided, or a ValidationError. """ error_type, help_msg, none_policy = pop_kwargs(kwargs, [('error_type', None), ('help_msg', None), ('none_policy', None)], allow_others=True) # the rest of keyword arguments is used as context. kw_context_args = kwargs return Va...
def is_valid(value, *validation_func, # type: Union[Callable, List[Callable]] **kwargs ): # type: (...) -> bool """ Validates value `value` using validation function(s) `validator_func`. As opposed to `assert_valid`, this function returns a boolean indicating if validation was a success or a failure. It is therefore de...
a friendly alias for `return _validator(validator_func, return_bool=True)(value)` :param validation_func: the base validation function or list of base validation functions to use. A callable, a tuple(callable, help_msg_str), a tuple(callable, failure_type), or a list of several such elements. Nested lists are supported...
will be transformed to functions automatically. :param value: the value to validate :param none_policy: describes how None values should be handled. See `NonePolicy` for the various possibilities. Default is `NonePolicy.VALIDATE`, meaning that None values will be treated exactly like other values and follow the same va...
:return: True if validation was a success, False otherwise """ none_policy = pop_kwargs(kwargs, [('none_policy', None)]) return Validator(*validation_func, none_policy=none_policy).is_valid(value)
def create_manually(cls, validation_function_name, # type: str var_name, # type: str var_value, validation_outcome=None, # type: Any help_msg=None, # type: str append_details=True, # type: bool **kw_context_args): """ Creates an instance without using a Validator. This method is not the primary way that errors are crea...
:param var_name: :param var_value: :param validation_outcome: :param help_msg: :param append_details: :param kw_context_args: :return: """ # create a dummy validator def val_fun(x): pass val_fun.__name__ = validation_function_name validator = Validator(val_fun, error_type=cls, help_msg=help_msg, **kw_context_args) # cr...
def get_details(self): """ The function called to get the details appended to the help message when self.append_details is True """ # create the exception main message according to the type of result if isinstance(self.validation_outcome, Exception): prefix = 'Validation function [{val}] raised ' if self.display_prefix...
validating {what}. ' + prefix + '{exception}: {details}')\ .format(what=self.get_what_txt(), val=self.validator.get_main_function_name(), exception=type(self.validation_outcome).__name__, details=end_with_dot(str(self.validation_outcome))) else: contents = 'Error validating {what}: validation function [{val}] returned ...
def get_variable_str(self): """ Utility method to get the variable value or 'var_name=value' if name is not None. Note that values with large string representations will not get printed :return: """ if self.var_name is None: prefix = '' else: prefix = self.var_name suffix = str(self.var_value) if len(suffix) == 0: suff...
> 0: return prefix + '=' + suffix else: return prefix + suffix
def assert_valid(self, name, # type: str value, # type: Any error_type=None, # type: Type[ValidationError] help_msg=None, # type: str **kw_context_args): """ Asserts that the provided named value is valid with respect to the inner base validation functions. It returns silently in case of success, and raises a `Validati...
programming') mode. By default this raises instances of `ValidationError` with a default message, in case of failure. There are two ways that you can customize this behaviour: * if you set `help_msg` in this method or in `Validator` constructor, instances of `ValidationError` created will be customized with the provide...
of your custom class will be created. Note that you may still provide a `help_msg`. It is recommended that Users define their own validation error types (case 2 above), so as to provide a unique error type for each kind of applicative error. This eases the process of error handling at app-level. :param name: the name o...
:param value: the value to validate :param error_type: a subclass of `ValidationError` to raise in case of validation failure. By default a `ValidationError` will be raised with the provided `help_msg` :param help_msg: an optional help message to be used in the raised error in case of validation failure. :param kw_cont...
to format the help message :return: nothing in case of success. Otherwise, raises a ValidationError """ try: # perform validation res = self.main_function(value) except Exception as e: # caught any exception: raise ValidationError or subclass with that exception in the details # --old bad idea: first wrap into a failur...
note: we do not have to 'raise x from e' of `raise_from`since the ValidationError constructor already # sets the __cause__ so we can safely take the same handling than for non-exception failures. res = e # check the result if not result_is_success(res): raise_(self._create_validation_error(name, value, validation_outco...
def _create_validation_error(self, name, # type: str value, # type: Any validation_outcome=None, # type: Any error_type=None, # type: Type[ValidationError] help_msg=None, # type: str **kw_context_args): """ The function doing the final error raising. """ # first merge the info provided in arguments and in self error_ty...
name name = self._get_name_for_errors(name) if issubclass(error_type, TypeError) or issubclass(error_type, ValueError): # this is most probably a custom error type, it is already annotated with ValueError and/or TypeError # so use it 'as is' new_error_type = error_type else: # Add the appropriate TypeError/ValueError b...
additional_type is None: # not much we can do here, let's assume a ValueError, that is more probable additional_type = ValueError new_error_type = add_base_type_dynamically(error_type, additional_type) # then raise the appropriate ValidationError or subclass return new_error_type(validator=self, var_value=value, var_na...
def is_valid(self, value # type: Any ): # type: (...) -> bool """ Validates the provided value and returns a boolean indicating success or failure. Any Exception happening in the validation process will be silently caught. :param value: the value to validate :return: a boolean flag indicating success or failure """ # n...
boolean indicating if success or failure return result_is_success(res) except Exception: # caught exception means failure > return False return False
def create_tags(user): """Create a tag.""" values = { 'id': utils.gen_uuid(), 'created_at': datetime.datetime.utcnow().isoformat() } values.update(schemas.tag.post(flask.request.json)) with flask.g.db_conn.begin(): where_clause = sql.and_( _TABLE.c.name == values['name']) query = sql.select([_TABLE.c.id]).where(where_c...
def get_tags(user): """Get all tags.""" args = schemas.args(flask.request.args.to_dict()) query = v1_utils.QueryBuilder(_TABLE, args, _T_COLUMNS) nb_rows = query.get_number_of_rows() rows = query.execute(fetchall=True) rows = v1_utils.format_result(rows, _TABLE.name) return flask.jsonify({'tags': rows, '_meta': {'count...
def delete_tag_by_id(user, tag_id): """Delete a tag.""" query = _TABLE.delete().where(_TABLE.c.id == tag_id) result = flask.g.db_conn.execute(query) if not result.rowcount: raise dci_exc.DCIConflict('Tag deletion conflict', tag_id) return flask.Response(None, 204, content_type='application/json')
def init_app(self, app, entry_point_group='invenio_assets.bundles', **kwargs): """Initialize application object. :param app: An instance of :class:`~flask.Flask`. :param entry_point_group: A name of entry point group used to load ``webassets`` bundles. .. versionchanged:: 1.0.0b2 The *entrypoint* has been renamed to *e...
def init_config(self, app): """Initialize configuration. :param app: An instance of :class:`~flask.Flask`. """ app.config.setdefault('REQUIREJS_BASEURL', app.static_folder) app.config.setdefault('COLLECT_STATIC_ROOT', app.static_folder) app.config.setdefault('COLLECT_STORAGE', 'flask_collect.storage.link') app.config.s...
def load_entrypoint(self, entry_point_group): """Load entrypoint. :param entry_point_group: A name of entry point group used to load ``webassets`` bundles. .. versionchanged:: 1.0.0b2 The *entrypoint* has been renamed to *entry_point_group*. """ for ep in pkg_resources.iter_entry_points(entry_point_group): self.env.reg...
def assert_instance_of(value, allowed_types # type: Union[Type, Tuple[Type]] ): """ An inlined version of instance_of(var_types)(value) without 'return True': it does not return anything in case of success, and raises a HasWrongType exception in case of failure. Used in validate and validation/validator :param value: t...
one match is enough to succeed. If None, type will not be enforced :return: """ if not isinstance(value, allowed_types): try: # more than 1 ? allowed_types[1] raise HasWrongType(wrong_value=value, ref_type=allowed_types, help_msg='Value should be an instance of any of {ref_type}') except IndexError: # 1 allowed_types =...
def assert_subclass_of(typ, allowed_types # type: Union[Type, Tuple[Type]] ): """ An inlined version of subclass_of(var_types)(value) without 'return True': it does not return anything in case of success, and raises a IsWrongType exception in case of failure. Used in validate and validation/validator :param typ: the ty...
one match is enough to succeed. If None, type will not be enforced :return: """ if not issubclass(typ, allowed_types): try: # more than 1 ? allowed_types[1] raise IsWrongType(wrong_value=typ, ref_type=allowed_types, help_msg='Value should be a subclass of any of {ref_type}') except IndexError: # 1 allowed_types = allow...
def validate(name, # type: str value, # type: Any enforce_not_none=True, # type: bool equals=None, # type: Any instance_of=None, # type: Union[Type, Tuple[Type]] subclass_of=None, # type: Union[Type, Tuple[Type]] is_in=None, # type: Container subset_of=None, # type: Set contains = None, # type: Union[Any, Iterable] sup...
type: int min_len=None, # type: int min_len_strict=False, # type: bool max_len=None, # type: int max_len_strict=False, # type: bool custom=None, # type: Callable[[Any], Any] error_type=None, # type: Type[ValidationError] help_msg=None, # type: str **kw_context_args): """ A validation function for quick inline validatio...
instance of any of `var_types` if provided * Value validation: * if `allowed_values` is provided, `value` should be in that set * if `min_value` (resp. `max_value`) is provided, `value` should be greater than it. Comparison is not strict by default and can be set to strict by setting `min_strict`, resp. `max_strict`, t...
than it. Comparison is not strict by default and can be set to strict by setting `min_len_strict`, resp. `max_len_strict`, to `True` :param name: the applicative name of the checked value, that will be used in error messages :param value: the value to check :param enforce_not_none: boolean, default True. Whether to enf...
instance_of: optional type(s) to enforce. If a tuple of types is provided it is considered alternate types: one match is enough to succeed. If None, type will not be enforced :param subclass_of: optional type(s) to enforce. If a tuple of types is provided it is considered alternate types: one match is enough to succeed...
optional set of allowed values. :param subset_of: an optional superset for the variable :param contains: an optional value that the variable should contain (value in variable == True) :param superset_of: an optional subset for the variable :param min_value: an optional minimum value :param min_strict: if True, only val...
True, only values strictly lesser than `max_value` will be accepted :param length: an optional strict length :param min_len: an optional minimum length :param min_len_strict: if True, only values with length strictly greater than `min_len` will be accepted :param max_len: an optional maximum length :param max_len_stric...
function or list of base validation functions to use. This is the same syntax than for valid8 decorators. A callable, a tuple(callable, help_msg_str), a tuple(callable, failure_type), or a list of several such elements. Nested lists are supported and indicate an implicit `and_`. Tuples indicate an implicit `_failure_ra...
a subclass of `ValidationError` to raise in case of validation failure. By default a `ValidationError` will be raised with the provided `help_msg` :param help_msg: an optional help message to be used in the raised error in case of validation failure. :param kw_context_args: optional contextual information to store in t...