iotoy.org/types/function

Note that the constraints specification is not fully decided yet, and as such should be interpreted as a person not as a machine. This will hopefully be tightened up

Please note, if you use a client that does not say "Accept: text/html" or similar, then you will get a response of application/json - suitable for machine parsing.

{
    "name" : "function",
    "description" : "Values that represent callable (via POST) functions - generally read only - GET/POST",
    "fieldspec" : {
        "value": {
            "regex" : "$match_json($ARG)",
            "constraints" : ["has_field($REPRESENTATION, 'name')",
                             "field_type($REPRESENTATION, 'name', 'string')",
                             "has_field($REPRESENTATION, 'spec')",
                             "field_type($REPRESENTATION, 'spec', 'obj')",
                             "has_field($REPRESENTATION, 'spec.args')",
                             "field_type($REPRESENTATION, 'spec.args','array')",
                             "allvalues($REPRESENTATION, 'spec.args', array_length($value) == 2)",
                             "allvalues($REPRESENTATION, 'spec.args', type($value) == 'string')",
                             "has_field($REPRESENTATION, 'spec.result')",
                             "field_type($REPRESENTATION, 'spec.result','array')",
                             "allvalues($REPRESENTATION, 'spec.result', array_length($value) == 2)",
                             "allvalues($REPRESENTATION, 'spec.result', type($value) == 'string')"
                            ],
            "interpretation" : "Function specification",
            "note" : "A JSON representation of a function object"
        },
        "href" : {
            "regex" : "^/([a-zA-Z_][a-zA-Z_0-9]*)(/([a-zA-Z_][a-zA-Z_0-9]*))*$",
            "constraint" : "(length($1)<30 and length($3)<30)",
            "interpretation" : "resourceid",
            "note" : "This should be the canonical URL path for the resource generally speaking - ala /some/resource/5"
        }, 
        "help" : {
            "regex" : "^\".*\"$",
            "constraint" : null,
            "interpretation" : "string",
            "note": "This is human readable text intended to convey to the user something about this value"
        },
        "type" : {
            "regex" : "^iotoy.org/types/function$",
            "constraint" : null,
            "interpretation" : "url description the type and constraints on the value",
            "note" : "Represents a link back to this description"            
        }
    }
}