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, )
class IBool(IField): """Boolean Field.""" default = Bool( title=_("Default Value"), description=_("""The field default value may be None or a legal field value"""))
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)
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"""))
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)
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."))
class IJSONField(IField): """A text field that stores A JSON.""" schema = Attribute( "schema", _("The JSON schema string serialization.") )
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)
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)
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)
class TooShort(ValidationError): __doc__ = _("""Value is too short""")
class TooLong(ValidationError): __doc__ = _("""Value is too long""")
class InvalidDottedName(ValidationError): __doc__ = _("""The specified dotted name is not valid.""")
class InvalidURI(ValidationError): __doc__ = _("""The specified URI is not valid.""")
class SchemaNotFullyImplemented(ValidationError): __doc__ = _("""Schema not fully implemented""")
class WrongContainedType(ValidationError): __doc__ = _("""Wrong contained type""")
class NotAContainer(ValidationError): __doc__ = _("""Not a container""")
class InvalidValue(ValidationError): __doc__ = _("""Invalid value""")
class ConstraintNotSatisfied(ValidationError): __doc__ = _("""Constraint not satisfied""")
class ITitledTokenizedTerm(ITokenizedTerm): """A tokenized term that includes a title.""" title = TextLine(title=_("Title"))
class NotAnIterator(ValidationError): __doc__ = _("""Not an iterator""")
class IJSONField(IField): """A text field that stores A JSON.""" json_schema = Attribute("json_schema", _("The JSON schema string serialization.")) schema_validator = Attribute("")
class NotUnique(ValidationError): __doc__ = _("""One or more entries of sequence are not unique.""")
class RequiredMissing(ValidationError): __doc__ = _("""Required input is missing.""")
class SchemaNotProvided(ValidationError): __doc__ = _("""Schema not provided""")
class WrongType(ValidationError): __doc__ = _("""Object is of wrong type.""")
class InvalidId(ValidationError): __doc__ = _("""The specified id is not valid.""")
class TooBig(ValidationError): __doc__ = _("""Value is too big""")
class Unbound(Exception): __doc__ = _("""The field is not bound.""")
class TooSmall(ValidationError): __doc__ = _("""Value is too small""")