Login
Back to bricks list
Introduction Version

DictValidator

Key-Value dictionnary validator.

This validator allows validating serialized (or deserialized) JSON values. An valid JSON value is a serializable/deserializable key-value dictionnary.

Usage: Let validator = DictValidator(), then * validator.validate('{"foo":0.5}') -> {"foo":0.5} * validator.validate('{"foo":0.5,"bar":[1,2,3]}') -> {"foo":0.5,"bar":[1,2,3]} * validator.validate('foo') -> ValueError * validator.validate('True) -> ValueError * validator.validate(''false') -> ValueError * validator.validate(''5.5') -> ValueError * validator.validate('[5.5,3]') -> ValueError * validator.validate([5.5,3]) -> ValueError

Functions

__INIT__

Initialize self. See help(type(self)) for accurate signature.

SET_TYPE
Parameters:
NameTypeDefault valueDescription
type_Union
VALIDATE

Valitates a value.

Parameters:
NameTypeDefault valueDescription
valueUnion The value to validate an instance of `bool`, `int`, `float`, `str` or serilaizable `list`, `dict`
Return type:
Any