Closed awhillas closed 8 years ago
In general it's acceptable an empty list, so there's no error (by design). You can specify how many selections are required using a refinement:
const Car = t.enums.of('Audi Chrysler Ford Renault Peugeot')
const atLeastOne = arr => arr.length > 0
const Type = t.struct({
car: t.refinement(t.list(Car), atLeastOne)
})
const options = {
fields: {
car: {
factory: t.form.Select
}
}
}
Ah cool, thanks!
I thought unless a field is wrapped in an t.maybe
then it was required.
Again, my bad.
Version
Tell us which versions you are using:
Expected behaviour
The multi selects are required and should pull a validation error when submit is called with anything selected.
Actual behaviour
No validation errors are called.
Steps to reproduce
t.emuns
inside at.list
like so:t.list(t.enums(tags))
t.list
and just using 't.enums(tags)', validation starts to work.The source code for this is a little complex as the structure is being dynamically generated from JSON:
with this code:
this get stuffed into t.Struct as a subform:
Am i building the subform correctly. It should look something like this:
where
tags = {124: 'tag1', 135: 'tag12'}
and with options like this:?