Module dexa_sdk.agreements.dda.v1_0.models.fields.context_field
Expand source code
from marshmallow import fields, ValidationError
class ContextField(fields.Field):
"""Field that serialises a JSONLD context,
it can be a list of strings or a string"""
def _serialize(self, value, attr, obj, **kwargs):
if not (isinstance(value, list) or isinstance(value, str)):
raise ValidationError(
"Context must be an instance of List[str] or str")
return value
def _deserialize(self, value, attr, data, **kwargs):
if not (isinstance(value, list) or isinstance(value, str)):
raise ValidationError(
"Context must be an instance of List[str] or str")
return value
Classes
class ContextField (*, default: Any = <marshmallow.missing>, missing: Any = <marshmallow.missing>, data_key: str = None, attribute: str = None, validate: Union[Callable[[Any], Any], Iterable[Callable[[Any], Any]]] = None, required: bool = False, allow_none: bool = None, load_only: bool = False, dump_only: bool = False, error_messages: Dict[str, str] = None, **metadata)
-
Field that serialises a JSONLD context, it can be a list of strings or a string
Expand source code
class ContextField(fields.Field): """Field that serialises a JSONLD context, it can be a list of strings or a string""" def _serialize(self, value, attr, obj, **kwargs): if not (isinstance(value, list) or isinstance(value, str)): raise ValidationError( "Context must be an instance of List[str] or str") return value def _deserialize(self, value, attr, data, **kwargs): if not (isinstance(value, list) or isinstance(value, str)): raise ValidationError( "Context must be an instance of List[str] or str") return value
Ancestors
- marshmallow.fields.Field
- marshmallow.base.FieldABC