Skip to content

Instantly share code, notes, and snippets.

@darkowlzz
Created April 26, 2013 06:13
Show Gist options
  • Save darkowlzz/5465332 to your computer and use it in GitHub Desktop.
Save darkowlzz/5465332 to your computer and use it in GitHub Desktop.
258 let labelledItemRules = mix(baseItemRules, {
259 label: {
260 map: stringOrNull,
261 is: ["string"],
262 ok: function (v) !!v,
263 msg: "The item must have a non-empty string label."
264 },
265 image: {
266 map: stringOrNull,
267 is: ["string", "undefined", "null"],
268 ok: function (url) {
269 if (!url)
270 return false;
271 return isLocalURL(url);
272 //return true;
273 }
274 }
275 });
276
277 // Validation for image URL
278 function isLocalURL(url) {
279 try {
280 return ['resource', 'data'].indexOf(URL(url).scheme) > -1;
281 }
282 catch(e) {}
283 return false;
284 }
285
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment