Comparing version 0.0.2-alpha to 0.0.3-alpha
@@ -33,5 +33,7 @@ 'use strict' | ||
for (const rule in rules) { | ||
if (!validate.number[rule] && | ||
if ( | ||
!validate.number[rule] && | ||
!validate.object[rule] && | ||
!validate.function[rule]) { | ||
!validate.function[rule] | ||
) { | ||
return __unknownRule(value, rule) | ||
@@ -58,2 +60,5 @@ } | ||
break | ||
case 'isExactly': | ||
_match = validate.object[rule](value, _compare) | ||
break | ||
case 'hasProperties': | ||
@@ -60,0 +65,0 @@ _match = validate.object[rule](value, _compare) |
@@ -13,4 +13,4 @@ 'use strict' | ||
}, | ||
isEqual: function (value, than) { | ||
return number.isNumber(value) && value === than | ||
isEqual: function (value, to) { | ||
return number.isNumber(value) && value === to | ||
}, | ||
@@ -17,0 +17,0 @@ isGreater: function (value, than) { |
@@ -25,2 +25,31 @@ 'use strict' | ||
return true | ||
}, | ||
/** | ||
* @todo instance cases: Date, Regexp ... | ||
*/ | ||
isExactly: function (value, to) { | ||
if (typeof to !== typeof value) { | ||
return false | ||
} | ||
if (typeof to === 'object') { | ||
if (to.constructor.name !== value.constructor.name) { | ||
return false | ||
} | ||
if (to instanceof Array) { | ||
for (let i = 0; i < to.length; i++) { | ||
if (!object.isExactly(value[i], to[i])) { | ||
return false | ||
} | ||
} | ||
return true | ||
} else { | ||
log.warning('check', 'object.isExactly, unknown instance', to.constructor.name) | ||
return false | ||
} | ||
} | ||
// primitives | ||
return value === to | ||
} | ||
@@ -27,0 +56,0 @@ } |
{ | ||
"name": "checkv", | ||
"version": "0.0.2-alpha", | ||
"version": "0.0.3-alpha", | ||
"description": "validator checker", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
# checkv | ||
! idiomatic | ||
--- | ||
@@ -4,0 +6,0 @@ |
6589
194
30