@view_config(
renderer="templates/form.pt", name="sequence_of_constrained_len"
)
@demonstrate("Sequence of Constrained Min and Max Lengths")
def sequence_of_constrained_len(self):
class Names(colander.SequenceSchema):
name = colander.SchemaNode(colander.String())
class Schema(colander.Schema):
names = Names(
validator=colander.Length(2, 4),
title="At Least 2 At Most 4 Names",
widget=deform.widget.SequenceWidget(min_len=2, max_len=4),
)
schema = Schema()
form = deform.Form(schema, buttons=("submit",))
return self.render_form(form)