Exemple #1
0
class IMinMaxLen(ILen):
    """Field requiring the length of its value to be within a range"""

    min_length = Int(
        title=_("Minimum length"),
        description=_("""
        Value after whitespace processing cannot have less than
        `min_length` characters (if a string type) or elements (if
        another sequence type). If `min_length` is ``None``, there is
        no minimum.
        """),
        required=False,
        min=0,  # needs to be a positive number
        default=0,
    )

    max_length = Int(
        title=_("Maximum length"),
        description=_("""
        Value after whitespace processing cannot have greater
        or equal than `max_length` characters (if a string type) or
        elements (if another sequence type). If `max_length` is
        ``None``, there is no maximum."""),
        required=False,
        min=0,  # needs to be a positive number
        default=None,
    )
Exemple #2
0
class IBool(IField):
    """Boolean Field."""

    default = Bool(
        title=_("Default Value"),
        description=_("""The field default value may be None or a legal
                        field value"""))
Exemple #3
0
class IMinMax(IOrderable):
    """Field requiring its value to be between min and max.

    This implies that the value needs to support the IOrderable interface.
    """

    min = Field(title=_("Start of the range"), required=False, default=None)

    max = Field(title=_("End of the range (including the value itself)"),
                required=False,
                default=None)
Exemple #4
0
class IInt(IMinMax, IField):
    """Field containing an Integer Value."""

    min = Int(title=_("Start of the range"), required=False, default=None)

    max = Int(title=_("End of the range (including the value itself)"),
              required=False,
              default=None)

    default = Int(
        title=_("Default Value"),
        description=_("""The field default value may be None or a legal
                        field value"""))
Exemple #5
0
class IDottedName(INativeStringLine):
    """Dotted name field.

    Values of DottedName fields must be Python-style dotted names.
    """

    min_dots = Int(title=_("Minimum number of dots"),
                   required=True,
                   min=0,
                   default=0)

    max_dots = Int(
        title=_("Maximum number of dots (should not be less than min_dots)"),
        required=False,
        default=None)
Exemple #6
0
class IDict(IMinMaxLen, IIterable, IContainer):
    """Field containing a conventional dict.

    The key_type and value_type fields allow specification
    of restrictions for keys and values contained in the dict.
    """

    key_type = Attribute(
        "key_type",
        _("Field keys must conform to the given type, expressed via a Field."))

    value_type = Attribute(
        "value_type",
        _("Field values must conform to the given type, expressed "
          "via a Field."))
Exemple #7
0
class IJSONField(IField):
    """A text field that stores A JSON."""

    schema = Attribute(
        "schema",
        _("The JSON schema string serialization.")
    )
Exemple #8
0
class ICollection(IMinMaxLen, IIterable, IContainer):
    """Abstract interface containing a collection value.

    The Value must be iterable and may have a min_length/max_length.
    """

    value_type = Field(
        title=_("Value Type"),
        description=_("Field value items must conform to the given type, "
                      "expressed via a Field."))

    unique = Bool(
        title=_('Unique Members'),
        description=_('Specifies whether the members of the collection '
                      'must be unique.'),
        default=False)
Exemple #9
0
class TooShort(ValidationError):
    __doc__ = _("""Value is too short""")

    def __init__(self, value, constraint, field_name=""):
        super().__init__(value=value,
                         constraint=constraint,
                         field_name=field_name)
Exemple #10
0
class IChoice(IField):
    """Field whose value is contained in a predefined set

    Only one, values or vocabulary, may be specified for a given choice.
    """
    vocabulary = Field(
        title=_("Vocabulary or source providing values"),
        description=_("The ISource, IContextSourceBinder or IBaseVocabulary "
                      "object that provides values for this field."),
        required=False,
        default=None)

    vocabularyName = TextLine(
        title=_("Vocabulary name"),
        description=_("Vocabulary name to lookup in the vocabulary registry"),
        required=False,
        default=None)
Exemple #11
0
class TooShort(ValidationError):
    __doc__ = _("""Value is too short""")
Exemple #12
0
class TooLong(ValidationError):
    __doc__ = _("""Value is too long""")
Exemple #13
0
class InvalidDottedName(ValidationError):
    __doc__ = _("""The specified dotted name is not valid.""")
Exemple #14
0
class InvalidURI(ValidationError):
    __doc__ = _("""The specified URI is not valid.""")
Exemple #15
0
class SchemaNotFullyImplemented(ValidationError):
    __doc__ = _("""Schema not fully implemented""")
Exemple #16
0
class WrongContainedType(ValidationError):
    __doc__ = _("""Wrong contained type""")
Exemple #17
0
class NotAContainer(ValidationError):
    __doc__ = _("""Not a container""")
Exemple #18
0
class InvalidValue(ValidationError):
    __doc__ = _("""Invalid value""")
Exemple #19
0
class ConstraintNotSatisfied(ValidationError):
    __doc__ = _("""Constraint not satisfied""")
Exemple #20
0
class ITitledTokenizedTerm(ITokenizedTerm):
    """A tokenized term that includes a title."""

    title = TextLine(title=_("Title"))
Exemple #21
0
class NotAnIterator(ValidationError):
    __doc__ = _("""Not an iterator""")
Exemple #22
0
class IJSONField(IField):
    """A text field that stores A JSON."""

    json_schema = Attribute("json_schema",
                            _("The JSON schema string serialization."))
    schema_validator = Attribute("")
Exemple #23
0
class NotUnique(ValidationError):
    __doc__ = _("""One or more entries of sequence are not unique.""")
Exemple #24
0
class RequiredMissing(ValidationError):
    __doc__ = _("""Required input is missing.""")
Exemple #25
0
class SchemaNotProvided(ValidationError):
    __doc__ = _("""Schema not provided""")
Exemple #26
0
class WrongType(ValidationError):
    __doc__ = _("""Object is of wrong type.""")
Exemple #27
0
class InvalidId(ValidationError):
    __doc__ = _("""The specified id is not valid.""")
Exemple #28
0
class TooBig(ValidationError):
    __doc__ = _("""Value is too big""")
Exemple #29
0
class Unbound(Exception):
    __doc__ = _("""The field is not bound.""")
Exemple #30
0
class TooSmall(ValidationError):
    __doc__ = _("""Value is too small""")