You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
+form schema = client action = some_action+list field = "contacts"+input field = "contacts.$.role"+link field = "contacts.$.contacts_id"
Now the list template offers list-specific add/remove buttons e.t.c, while the contents of the list
validate according to the schema keys under contacts.$.contacts_id and contacts.$.role
The problem, however is that each element of the list references the same schema key, and thus share the same validation context state
Solution?
given that the validation state as supplied by validateOne is per instance, while the schema key is per type a mapping between the two would come in handy.
Note that this has little to do with the validation context, as the same field-schemas need to validate more than once in the same validation context. With arrays that is once per array element.
I am proposing to introduce a mapper function, with this sensible default:
schema_for_field= (field_name, schema)->if schema[field_name]
return field_name
transformed=field_name.split('.').map (field_name_element)->if/d+/.exec field_name_element
"$"# This is a list indexelse
field_name_element #this is a schema indextransformed.join"."
The beauty of this is that it is exensible, such that validation would also be possible for patterns of field names. Say you wanted to validate according to some field-schema all fields starting with max, then you could map the field name (field)->field.startsWith "min" and "min" or field
The validation state would still need to be stored for each field_name as supplied by the field=<field_name> template parameter.
Sorry for the lengthy post, but i hope the proposal is worth considering.
The text was updated successfully, but these errors were encountered:
The problem arose when creating a variable length array, each element being a validated object like this (coffee)
First apologies, for using coffee & jade, but it makes the issue a bit less verbose. I can translate the examples if that's an issue
Now creating a form would look like this (jade):
Now the
list
template offers list-specificadd
/remove
buttons e.t.c, while the contents of the listvalidate according to the schema keys under
contacts.$.contacts_id
andcontacts.$.role
The problem, however is that each element of the list references the same schema key, and thus share the same validation
contextstateSolution?
given that the validation state as supplied by
validateOne
is per instance, while the schema key is per type a mapping between the two would come in handy.Note that this has little to do with the validation context, as the same field-schemas need to validate more than once in the same validation context. With arrays that is once per array element.
I am proposing to introduce a mapper function, with this sensible default:
The beauty of this is that it is exensible, such that validation would also be possible for patterns of field names. Say you wanted to validate according to some field-schema all fields starting with
max
, then you could map the field name(field)->field.startsWith "min" and "min" or field
The validation state would still need to be stored for each
field_name
as supplied by thefield=<field_name>
template parameter.Sorry for the lengthy post, but i hope the proposal is worth considering.
The text was updated successfully, but these errors were encountered: