Support template data validation by adding required fields (minimal dataset) and regular expression validation. A non-required field can still be validated by a regular expression, if a value has been provided.
- Add an optional property to the
data
object: required (boolean) - Add an optional property to the
data
object: regexp (string pattern)
{ "collection" :
{
"version" : "1.0",
"href" : "http://example.org/users",
"template" : {
"data" : [
{"name" : "username", "value" : "", "prompt" : "Login Name", "regexp" : "^[a-zA-Z0-9]*$", "required" : "true"},
{"name" : "email", "value" : "", "prompt" : "Email", "regexp" : "^[\w\d.@]*$", "required" : "true"},
{"name" : "gender", "value" : "", "prompt" : "Gender", "regexp" : "^(m|f)$"}
]
}
}
}