-
-
Save akb/3239303 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ORIGINAL SCHEMA image.json : | |
{ | |
"type":"object", | |
"id":"#image", | |
"properties":{ | |
"name": { "type":"string"}, | |
"encoding": { "type":"string"}, | |
"drcid": { "type":"string"}, | |
"type": { "type":"string"}, | |
"environment": { "type":"string"}, | |
"content": { "type":"string"} | |
} | |
} | |
MODEL COFFEE FILE image.coffee : | |
window.models = {} unless window.models? | |
imageSchema = | |
"type":"object" | |
"id":"#image" | |
"properties": | |
"name": { "type":"string" } | |
"encoding": { "type":"string" } | |
... | |
class models.Image extends Backbone.Model | |
idAttribute: "name" | |
urlRoot: "/images" | |
defaults: | |
name: "" | |
encoding: "" | |
drcid: "" | |
type: "" | |
environment: "" | |
validate: (attrs) -> | |
unless typeof attrs.encoding is "string" | |
return "Encoding must be a string." | |
unless typeof attrs.drcid is "string" | |
return "Drcid must be a string." | |
unless typeof attrs.type is "string" | |
return "Type must be a string." | |
unless typeof attrs.environment is "string" | |
return "Environment must be a string." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment