
Show HN: Form-validation.js – JavaScript form validation library - iendeavor
https://github.com/iendeavor/form-validation.js
======
wackget
Sorry but that example code looks confusing as hell. If I saw that code
without any context, I really wouldn't be able to tell you what it's doing.

Seriously, this is why I hate modern web development. Absolutely everything
seems stuffed full of incredibly over-the-top complexity.

Libraries like jQuery get a lot of hate because they're not trendy or
supposedly impact performance too much, but unless you're serving thousands of
visitors simultaneously you really should care more about code readability and
maintainability than any of that.

At least with something like jQuery validation you can actually understand
what the code is doing:

    
    
      $("#myform").validate({
        rules: {
          name: "required",
          email: {
            required: true,
            email: true
          }
        },
        messages: {
          name: "Please specify your name",
          email: {
            required: "We need your email address to contact you",
            email: "Your email address must be in the format of name@domain.com"
          }
        }
      });

------
hashamali
I've been pretty happy with Formik
([https://formik.org/docs/overview](https://formik.org/docs/overview)) for the
past few years. Any comparison to this library?

~~~
bilalakbar
React Hook Form is gaining traction these days.

[https://react-hook-form.com/](https://react-hook-form.com/)

------
majkinetor
I prefer standards.

For example json-editor:

[https://github.com/json-editor/json-editor](https://github.com/json-
editor/json-editor)

It uses json schema validators that have big toolset available.

~~~
oweiler
JSON Schema is no official standard.

~~~
majkinetor
From practical standpoint, it is.

------
p2hari
The link for live example does not check for the rule between 3-5 characters
for activity name. The rule.js needs to return true for minLength. Just posted
it here instead of creating issue, hope it is fine.

~~~
iendeavor
Thanks for reply, I've fix it in the rule.js.

------
nsonha
Wow yet another validation library, this one is special because it doesnt care
about typescript.

Seriously a big part of the problem is to infer type information as you write
validators. Anyone can just invent a dsl for type schema. Npm already has heap
of these. If we want the schema approach we' probably go with something json-
schema based.

Have a look at io-ts and runtypes to see what what a modern js validator
should look like (again has something to do with typescript)

------
VoidWhisperer
It is nice that this has no dependencies, but this strikes me as adding a
massive amount of boilerplate than what would be normally necessary due to the
flexibility.

------
somishere
What problem is this resolving? A short intro on the repo might help. Maybe
I'm missing the point but I implement validation using standard browser APIs
semi-regularly. It used to be painful, these days it is incredibly
straightforward. The only place I would potentially consider a validation
library is as a side-loaded polyfill for IE. Please explain?

~~~
iendeavor
Thanks for reply,

> What problem is this resolving

A lot of validation framework doesn't pass `path` (key is not enough in
complex situations) to rules to achieve cross-field validation.

> ... these days it is incredibly straightforward.

I've also read HTML5 standard validation APIs, the APIs is not easy to deal
with (at least for me). for example, again, do cross-field validation.

> ... polyfill for IE.

Sorry about this, form-validation.js is based on modern javascript feature:
Proxy (In order to simulate the data-structure of the form you passed in),
There is no possible to provide polyfill for Promise

Hope this helps you well, I'll add some intro to READMD.md when I am free.

------
jeffhandley
If you’re looking for something with less boilerplate but still extensive
extensibility, check out [https://strickland.io](https://strickland.io). It
also has no dependencies and is pure JavaScript.

------
bg0
If you're looking for something a bit more minimal, check out Pristine:
[http://pristine.js.org/](http://pristine.js.org/)

