Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// Define in some kind of registry a prototype for all the Employee objects
.attribute({name: "emailAddress", type: "Email"})
name: "birthDate",
type: "Date",
constraints: [{
validator: function (v) {
return (v.timestamp() <;
errorMessage: "Birth date must be in the past"
.attribute({name: "notes", type: "MultilineText", rendering: "AllowSafeHtml"})
.link({name: "employer", entity: "Company"})
.link({name: "photo", entity: "Image"});
// Then, to show a new object edit form
// Which is validated on submission
var submitted = entity('Employee').readForm(httpPost);
if (submitted) {
} else {
// Render with error messages for invalid fields
entity('Employee').renderHtmlForm('full_featured.tmpl', httpPost);
// Then, to edit an existing object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment