Source code for cion.options
"""Options to be used with :class:`cion.Schema`"""
from enum import Enum
__all__ = ("Options", "ExtraFields")
[docs]class Options:
"""Schema Options"""
extra: ExtraFields = ExtraFields.IGNORE
stop_on_error: bool = False
[docs] def __init__(
self,
*,
extra: ExtraFields = ExtraFields.IGNORE,
stop_on_error: bool = False,
) -> None:
"""Class for creating Schema options
Args:
extra: What to do when there are extra fields in the data
See the docs for :class:``cion.options.ExtraFieldsOption``
stop_on_error: Whether or not to continue after an error
If ``True``, when an error is raised, stop immediately and throw an error
If ``False``, when an error is raised, compile a list of errors and throw the error after validation is done
Essentially, this option dictates whether you want to receive any validated data on error, or wait to get all the valid data
"""
self.extra = extra
self.stop_on_error = stop_on_error