Skip to content
This repository was archived by the owner on Apr 8, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,17 @@ This tool is a work-in-progress and still doesn't adhere to the full specs (yet)
Plans to support the full microdata spec + data vocabulary validation are on
the drawing board. ;)

Thanks to [@peterhost](https://github.com/peterhost) we now have a bookmarklet available
(source: https://gist.github.com/1397528) for your use without having to modify your page's source code!
Simply visit [this page](http://jsfiddle.net/peterhost/ZJfpL/14/embedded/result/) and drag
the link to your bookmark bar and you're set to go.
#UPDATE 6.03.2014#

-- schemas.js: Added 106 new classes with properties accordingly to official Schema Version 1.0f

-- jquery.microdata.js: Added validations for number and data

-- file schemas-stub.js added. File contains the part of code for adding new classes/properties to schemas.js.
For adding new classes/properties: open schemas-stub.js, copy and edit code, add the code to schemas.js, like it done there.

-- [Go to this page and drop the given link to your bookmarks](http://jsfiddle.net/chilly_bang/mf3xt/embedded/result/) This bookmarklet works with updated and enriched schemas.js and jquery.microdata.js and is based on this one from [@peterhost](https://gist.github.com/1397528).

#UPDATE 11.03.2014#

-- added extended action classes
10 changes: 9 additions & 1 deletion jquery.microdata.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,15 @@

float: function(value, el) { return (/^\d+([.,]\d*)?$/).test(value); },

// ADD 6.03.2014: Number (both of int and float) Validation
number: function(value, el) { return (/(\d+(.\d+)?)/).test(value); },

// ADD 6.03.2014: Date Validation
date: function(value, el) { return (/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/).test(value); },

// TODO: need a proper datetime validator
datetime: function(value, el) { return (/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2})?)?$/).test(value); },
// TODO: check the duration per http://en.wikipedia.org/wiki/ISO_8601#Durations
duration: function(value, el) { return (/^P(([0-9.,]+[YMD])*(T[0-9.,]+[HMS])*|[0-9.,]W)$/).test(value); },

Expand All @@ -44,6 +50,8 @@
// TODO: check three-letter ISO code for currency: http://www.iso.org/iso/support/faqs/faqs_widely_used_standards/widely_used_standards_other/currency_codes.htm
currency: function(value, el) { return (/^[a-zA-Z]{3}$/).test(value); },

//Validation TODOs: Geocoordinates, Geo-shape, Country: two-letter ISO 3166-1 alpha-2

any: function(value, el) { return true; },

boolean: function(value, el) { return (/(True|False)/i).test(value); }
Expand Down
18 changes: 18 additions & 0 deletions schemas-stub.js.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
schemaOrg.push({
url: "http://schema.org/Class", // Class to describe
fields: extend(findByUrl(schemaOrg, "http://schema.org/ParentClass"), [ //Parent class

{name: "exampleProperty", required: false, type: "complex", validator: validators.complex }, // List of (mostly validated) Properties
{name: "", required: false, type: "text", validator: validators.text }, // Validations are done in the jquery.microdata.js
{name: "", required: false, type: "url", validator: validators.url }, // Property type "complex" is the property, with expected type is a node/another class
{name: "", required: false, type: "date", validator: validators.date },
{name: "", required: false, type: "datetime", validator: validators.datetime},
{name: "", required: false, type: "duration", validator: validators.duration},
{name: "", required: false, type: "number", validator: validators.number },
{name: "", required: false, type: "int", validator: validators.int },
{name: "", required: false, type: "boolean", validator: validators.boolean },
{name: "", required: false, type: "email", validator: validators.email },
{name: "", required: false, type: "currency", validator: validators.currency}

])
});
Loading