akidee / schema.js

Sophisticated JSON schema based data validation and adaptation
MIT License
173 stars 13 forks source link

typeof #9

Open dvv opened 13 years ago

dvv commented 13 years ago

Hi!

I'm sure you're aware of JS quirks in type detection, and e.g. typeof (new Number(4)) === 'object'. This can completely break coercion logic. I'd suggest to use robust _.isXXX() to determine the types of the instances, given you already required _ as dependency.

Best regards, --Vladimir++

akidee commented 13 years ago

Using _'s type checkers is not acceptable (on the server side), their performance is too low. I agree to another field (like "safetyping: true") in this case. For what do you need a number/boolean/... object?

dvv commented 13 years ago

I personally do not need these objects. But this is quite a valid use case, so we should account for it.

What to real implementation, it's up to you. Personally, I'm inclined to state that speed is good, but not as direct tradeoff of algorythm confidence.