Skip to content

Instantly share code, notes, and snippets.

@CharlotteGore
Created November 4, 2013 13:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CharlotteGore/7302318 to your computer and use it in GitHub Desktop.
Save CharlotteGore/7302318 to your computer and use it in GitHub Desktop.
Controls proposal
editresource : {
method : "PUT",
action : "/someaction",
encoding: "x-form-www-encoding"
properties : {
"username" : "Current Username",
"email" : "current@user.com",
"etag" : "123j123j1llkj31ljflkjsdlkj32lkjlkjf",
"things" : [1, 2]
},
schema : {
"username" : {
type : "Text",
validators : [
required : true,
pattern : /[A-Za-z0-9\s]/
]
},
"email" : {
type : "Email",
validators : [
required : false
]
},
"etag" : {
type : "Hidden",
validators : [
required : true,
pattern : /[A-Za-z0-9\s]/
]
},
"things" : {
type : "SelectMany",
validators : [
required: true
],
options : [
{
value : 1,
description : "Option one"
},
{
value : 2,
description : "Option two"
},
{
value : 3,
description : "Option three"
}
]
/*
// or this could actually be...
options : [1, 2, 3]
// which would just generate <option value="1">1</option>
*/
}
},
enum : ["username", "email", "things", "etag"]
}
@ismasan
Copy link

ismasan commented May 9, 2014

Hi.

I'm currently looking into adding actions/forms to my HAL API and was wondering whether this solution has evolved since you posted it and if you've got any insights after using it in production.

I'm also thinking I'll use JSON Schema to describe options and payloads so I can reuse existing tools to generate and validate the schemas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment