validate.js icon indicating copy to clipboard operation
validate.js copied to clipboard

Dynamic constraints

Open crs1138 opened this issue 8 years ago • 1 comments

I've got a massive dynamic form, where I need to check vast majority of the fields for a regex pattern /^([awx]|\d+)$/. These fields are generated from data and appropriate name attributes have following naming convention:

id_pretest_situps, id_pretest_pushups, id_posttest_situps, id_posttest_pushups,… so once generated I might have 30–50 pretest_situps and posttest_situps…

these are all inputs like the following example…

<input type="text" id="0_pretest_knowledge_test" name="0_pretest_knowledge_test" class="form-control text-right" placeholder="1" value="2">

So I've got later all these unique names…

0_pretest_situps, 0_posttest_situps 1_pretest_situps, 1_posttest_situps 2_pretest_situps, 2_posttest_situps 3_pretest_situps, 3_posttest_situps 4_pretest_situps, 4_posttest_situps etc…

is there a way how to validate all these for all these different names if I want to make sure the input values match the regex /^([awx]|\d+)$/?

crs1138 avatar Oct 25 '17 16:10 crs1138

The easiest would probably be to define a custom validator that either delegates to format or validates itself.

ansman avatar Nov 12 '17 04:11 ansman