News for hackers. Stuff that matters.
Re:V8n – Fluent validation library for JavaScript by partycoder on Sunday July 15, 2018 @03:02PM (#17536487)
This should be a Show HN.

I read the code, and I do not think this library is suitable for real-world use.

Consider `makeTestType` (https://github.com/imbrn/v8n/blob/master/src/v8n.js#L973-L98...):

    return () => value => {
      return (
        typeof value === type ||
        (value === null && type === "null") ||
        (Array.isArray(value) && type === "array")
      );
    };
This means that null and "null" (as a string) are now numbers.

    v8n().number().test("null") // true
It also means that an array of numbers is a number... something that is counterintuitive for the user of the library.

In addition to that, most of the time you want to deal with finite numbers. A validation library should have an API that reflects this, but this is not the case for v8n.

Re:V8n – Fluent validation library for JavaScript by twiss on Sunday July 15, 2018 @03:39PM (#17536675)
No, it doesn't mean that. You can try it out here: https://runkit.com/embed/ev53mh0z4nxt

`makeTestType("null")()(null)` return true, but `makeTestType("number")()(null)` doesn't. The signature of `makeTestType` is `type: String => () => value: Any => Boolean`.