Permalink
Browse files

Implement boolean type-casting

  • Loading branch information...
ixti committed Oct 29, 2012
1 parent 5105887 commit f85d547c4261f7dc55a701bac415dccfa5547757
Showing with 10 additions and 0 deletions.
  1. +10 −0 lib/revalidator.js
View
@@ -241,6 +241,16 @@
if (('integer' === schema.type || 'number' === schema.type) && value == +value) {
value = +value;
}
+
+ if ('boolean' === schema.type) {
+ if ('true' === value || '1' === value || 1 === value) {
+ value = true;
+ }
+
+ if ('false' === value || '0' === value || 0 === value) {
+ value = false;
+ }
+ }
}
if (schema.format && options.validateFormats) {

0 comments on commit f85d547

Please sign in to comment.