Hi Piotr,
One approach that you could try is having the types that you expect to validate against as a separate field consisting of your sequence types. When your form is submitted, you would read that field first and dynamically generate the schema you wish to validate the rest of your request against. Alternatively, you could have the validation type and element data as sub objects to your request and then validate each type based on the validation type field. That was probably a bit confusing, so are some examples of what your form posts would look like as JSON:
types: [ 'iPhone', 'android', 'windowsPhone'],
fields: [
{
iosVersion: '...'
serialNumber: '...'
},
{
androidVersion: '...',
serialNumber: '...'
},
{
windowsVersion: '...',
productId: '...'
}
]
- or -
fields: [
{
type: 'iPhone',
data: {
iosVersion: '...'
serialNumber: '...'
},
{
type: 'android',
data: {
androidVersion: '...',
serialNumber: '...'
},
{
type: 'windowsPhone',
data: {
windowsVersion: '...',
productId: '...'
}
]
I don't have too much experience with Deform, but I have used Colander quite extensively. Unfortunately, this will require some programming on your part to dynamically build the schema to validate against whenever your form is submitted.
Hope this helps!
-Vincent