Types Schema
Contents
Types Schema#
The following is a detailed list of all available Zope Schema field types and their corresponding representation as JSON objects.
TextLine#
Zope Schema:
zope.schema.TextLine(
title="My field",
description="My great field",
default="foobar"
)
JSON:
{
"type": "string",
"title": "My field",
"description": "My great field",
"default": "foobar"
}
Text#
Zope Schema:
zope.schema.Text(
title="My field",
description="My great field",
default="Lorem ipsum dolor sit amet",
min_length=10,
)
JSON:
{
"type": "string",
"title": "My field",
"description": "My great field",
"widget": "textarea",
"default": "Lorem ipsum dolor sit amet",
"minLength": 10
}
Bool#
Zope Schema:
zope.schema.Bool(
title="My field",
description="My great field",
default=False,
)
JSON:
{
"type": "boolean",
"title": "My field",
"description": "My great field",
"default": false
}
Float#
Zope Schema:
zope.schema.Float(
title="My field",
description="My great field",
min=0.0,
max=1.0,
default=0.5,
)
JSON:
{
"minimum": 0.0,
"maximum": 1.0,
"type": "number",
"title": "My field",
"description": "My great field",
"default": 0.5
}
Decimal#
Zope Schema:
zope.schema.Decimal(
title="My field",
description="My great field",
min=Decimal(0),
max=Decimal(1),
default=Decimal(0.5),
)
JSON:
{
"minimum": 0.0,
"maximum": 1.0,
"type": "number",
"title": "My field",
"description": "My great field",
"default": 0.5
},
Int#
Zope Schema:
zope.schema.Int(
title="My field",
description="My great field",
min=0,
max=100,
default=50,
)
JSON:
{
"minimum": 0,
"maximum": 100,
"type": "integer",
"title": "My field",
"description": "My great field",
"default": 50
}
Choice#
Zope Schema:
zope.schema.Choice(
title="My field",
description="My great field",
vocabulary=self.dummy_vocabulary,
)
JSON:
{
"type": "string",
"title": "My field",
"description": "My great field",
"enum": ["foo", "bar"],
"enumNames": ["Foo", "Bar"],
"choices": [
{"foo": "Foo"},
{"bar": "Bar"}
]
}
List#
Zope Schema:
zope.schema.List(
title="My field",
description="My great field",
min_length=1,
value_type=schema.TextLine(
title="Text",
description="Text field",
default="Default text"
),
default=["foobar"],
)
JSON:
{
"type": "array",
"title": "My field",
"description": "My great field",
"default": ["foobar"],
"minItems": 1,
"uniqueItems": false,
"additionalItems": true,
"items": {
"type": "string",
"title": "Text",
"description": "Text field",
"default": "Default text"
}
},
Tuple#
Zope Schema:
field = zope.schema.Tuple(
title="My field",
value_type=schema.Int(),
default=(1, 2),
)
JSON:
{
"type": "array",
"title": "My field",
"description": "",
"uniqueItems": true,
"additionalItems": true,
"items": {
"title": "",
"description": "",
"type": "integer"
},
"default": [1, 2]
}
Set#
Zope Schema:
field = zope.schema.Set(
title="My field",
value_type=schema.TextLine(),
)
JSON:
{
"type": "array",
"title": "My field",
"description": "",
"uniqueItems": true,
"additionalItems": true,
"items": {
"title": "",
"description": "",
"type": "string"
}
}
List of Choices#
Zope Schema:
field = zope.schema.List(
title="My field",
value_type=schema.Choice(
vocabulary=self.dummy_vocabulary,
),
)
JSON:
{
"type": "array",
"title": "My field",
"description": "",
"uniqueItems": true,
"additionalItems": true,
"items": {
"title": "",
"description": "",
"type": "string",
"enum": ["foo", "bar"],
"enumNames": ["Foo", "Bar"],
"choices": [
{"foo": "Foo"},
{"bar": "Bar"}
]
}
}
Object#
Zope Schema:
zope.schema.Object(
title="My field",
description="My great field",
schema=IDummySchema,
)
JSON:
{
"type": "object",
"title": "My field",
"description": "My great field",
"properties": {
"field1": {
"title": "Foo",
"description": "",
"type": "boolean"
},
"field2": {
"title": "Bar",
"description": "",
"type": "string"
}
}
}
RichText (plone.app.textfield
)#
Zope Schema:
from plone.app.textfield import RichText
field = RichText(
title="My field",
description="My great field",
)
JSON:
{
"type": "string",
"title": "My field",
"description": "My great field",
"widget": "richtext"
}
Date#
Zope Schema:
zope.schema.Date(
title="My field",
description="My great field",
default=date(2016, 1, 1),
)
JSON:
{
"type": "string",
"title": "My field",
"description": "My great field",
"default": "2016-01-01",
"widget": "date"
}
DateTime#
Zope Schema:
zope.schema.Datetime(
title="My field",
description="My great field",
)
JSON:
{
"type": "string",
"title": "My field",
"description": "My great field",
"widget": "datetime"
}
Email#
Zope Schema:
plone.schema.Email(
title="My field",
description="My great field",
)
JSON:
{
"type": "string",
"title": "My field",
"description": "My great field",
"widget": "email"
}
Password#
Zope Schema:
zope.schema.Password(
title="My field",
description="My great field",
)
JSON:
{
"type": "string",
"title": "My field",
"description": "My great field",
"widget": "password"
}
URI#
Zope Schema:
zope.schema.URI(
title="My field",
description="My great field",
)
JSON:
{
"type": "string",
"title": "My field",
"description": "My great field",
"widget": "url"
}