Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

27 lines (21 sloc) 0.961 kb

Template Data Validation

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, iff a value has been provided.

  1. Add an optional property to the data object: required (boolean)
  2. 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)$"}
      ]
    }
  }
}

References

  1. https://groups.google.com/forum/#!topic/collectionjson/RPQcM_WX7Y0
Jump to Line
Something went wrong with that request. Please try again.