diff --git a/examples/validate/README.md b/examples/validate/README.md new file mode 100644 index 0000000..b4f1570 --- /dev/null +++ b/examples/validate/README.md @@ -0,0 +1,4 @@ +ScriptForm validate example +=========================== + +This example shows extra validation options for fields. diff --git a/examples/validate/job_validate.sh b/examples/validate/job_validate.sh new file mode 100755 index 0000000..51989b6 --- /dev/null +++ b/examples/validate/job_validate.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +echo "string = $string" +echo "integer = $integer" +echo "float = $float" +echo "date = $date" diff --git a/examples/validate/validate.json b/examples/validate/validate.json new file mode 100644 index 0000000..4d48eb2 --- /dev/null +++ b/examples/validate/validate.json @@ -0,0 +1,45 @@ +{ + "title": "Validation example", + "forms": { + "validate": { + "title": "Validated form", + "description": "This form is heavily validated", + "submit_title": "Validate it", + "script": "job_validate.sh", + "fields": [ + { + "name": "string", + "title": "A string between 5 and 7 characters.", + "type": "string", + "required": true, + "minlen": 5, + "maxlen": 7 + }, + { + "name": "integer", + "title": "An integer between 10 and 20", + "type": "integer", + "required": true, + "min": 10, + "max": 20 + }, + { + "name": "float", + "title": "A real number between 0.5 and 1", + "type": "float", + "required": true, + "min": 0.5, + "max": 1.0 + }, + { + "name": "date", + "title": "A date", + "type": "date", + "required": true, + "min": "2015-01-01", + "max": "2015-02-01" + } + ] + } + } +}