-
-
Save Marak/bf21229c7a1d6ae02884 to your computer and use it in GitHub Desktop.
starting to define schema for Resource
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
var description = { | |
"default": "", | |
"description": "the description of the property" | |
}; | |
var message = { | |
"default": "", | |
"description": "custom error message to be shown on error" | |
}; | |
var conform = { | |
"default": function(val) { | |
return val; | |
}, | |
"description": "value must satisify this custom method" | |
}; | |
var fakeSchema = { | |
"String": { | |
"default": { | |
"default": "", | |
"description": "the default value ( a string )" | |
}, | |
"description": description, | |
"format": { | |
"default": "", | |
"description": "a pre-defined format the value should match", | |
"enum": ["email", "url"] | |
}, | |
"message": message, | |
"minLength": { | |
"default": 0, | |
"description": "the minimum length of the string" | |
}, | |
"maxLength": { | |
"default": 10, | |
"description": "the maximum length of the string" | |
}, | |
"enum": { | |
"default": "[]", | |
"description": "value must be contained in this array" | |
}, | |
"pattern": { | |
"default": new RegExp(), | |
"description": "value must satisify this regex pattern" | |
}, | |
"conform": conform | |
}, | |
"Number": { | |
"default": { | |
"default": 0, | |
"description": "the default value ( a number )" | |
}, | |
"description": description, | |
"message": message, | |
"minimum": { | |
"default": 0, | |
"description": "the default value ( a number )" | |
}, | |
"maximum": { | |
"default": 0, | |
"description": "the default value ( a number )" | |
}, | |
"conform": conform | |
}, | |
"Boolean": { | |
"default": { | |
"default": false, | |
"description": "the default value ( a boolean )" | |
}, | |
"description": description, | |
"message": message | |
}, | |
"Array": { | |
"default": { | |
"default": "[]", | |
"description": "the default value ( an array )" | |
}, | |
"description": description, | |
"message": message | |
}, | |
"Object": { | |
"default": { | |
"default": "{}", | |
"description": "the default value ( an object )" | |
}, | |
"description": description, | |
"message": message | |
} | |
}; |
There's a bunch of stuff missing and wrong here. This isn't for review, it was a reference for myself.
No need to point it out. It's why I made a ticket and linked this from flatiron/resourceful#115
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Number actually have "within" defined as an array of two: minimum, maximum
String have "Length" likewise an array :minLength, maxLength - have to say that they fail
The exclusiveMinimum.. Are actually implemented in revalidator, so should easily be in the resourceful.
Sanitize is currently a chained function if using bultins (abs, upper...) , but a property if you customize
I made https://github.com/raix/resourceful/wiki/Define-resources where i tried to (tried some markdown, not quite there...) but then i discovered the revalidator api witch speakes of the json schema. Well still learning, kind of a newbe here :)