brainly/jvalidator — pull request #2 by daarond (2014-05-17 23:51:07+00:00)
Title: Added Coercion

Changes:
-json and schema can be a parsed object as well as a json string
-Added coerce property to Validator object, triggering coercion mode
-Coerce rules:
* Array:
--no default sends errors like before
--when not an array, sets element value to default
--items < minimum, sets element value to default
--items > maximum, truncates to maximum items
--when not unique, removes non-unique values
* Boolean:
--no default sends errors like before
--when not a boolean, sets element value to default
* Integer:
--no default sends errors like before
--when not an integer, sets element value to default
--items < minimum, sets element value to default
--items > maximum, sets element value to default
--when not in enum, sets element value to default
* Null:
--no default sends errors like before
--when not null, sets element value to null
* Number:
--no defaults sends errors like before
--when not a number, sets element value to default
--items < minimum, sets element value to default
--items > maximum, sets element value to default
--when not in enum, sets element value to default
* Object:
--no defaults sends errors like before
--when not an object, sets element value to default
* String:
--no default sends errors like before
--when not a string, sets element value to default
--length < minimum, sets element value to default
--length > maximum, truncates value to maximum
--when not in enum, sets element value to default
* Union
--no changes