journey and making them more confident and happy • <50% of major online E-Commerce players either aren't doing it or are doing it incorrectly • Losing money • Alienating users
HTML5 validate API • Generally a one-to-one mapping between fields and validations • Different fields respond to different event life-cycles for capturing their values across different types of validations e.g. onChange, onBlur, onKeypress • Poor support for adding validations dynamically if (country = 'UK') { // do post code validation } • Poor support for asynchronous field validation and how to reconcile these with synchronous validations
messages aren't able to be styled consistently and are wrong • All in one solutions require you to use their form fields which can be a huge burden and means your bound by their styling output as to how your fields look
validations and messages • JavaScript based stack alleviates that to a degree • Most other solutions basically copy and codify constraints and error messages so are prone to misalignment over time • Impossible to cover all use cases regardless of stack e.g. username uniqueness, date overlaps
2. Poor styling support and no control over markup 3. Impossible to align backend data constraints and error messages with the on the client 4. Accept server side validations exist always and how to reconcile them
2. Poor styling support and no control over markup 3. Impossible to align backend data constraints and error messages with the on the client 4. Accept server side validations exist always and how to reconcile them
attaching these easier • Makes handling UI state and as an extension of that dynamic form state a breeze • Smoothes over browser quirks for event lifecycles e.g. onChange • Heavily favours composition • Controlled forms have a consistent easy to use API
just one function here, so you can compose them using ES6 imports • The validation functions are run in the order they're passed in • Validations bail out as soon as the first one returns any errors https://codesandbox.io/s/jnyv95r26w
to work at the form level context for handling validations as you get the entire form state to work with and inspect • You also get access to the eventPhase as these validations are run both onChange and onBlur https://codesandbox.io/s/jnyv95r26w
side validation message and value which prompted the message • Accessible through initialErrors in validation function - developers can do what they like with it - choose to use it or ignore it
2. Poor styling support and no control over markup 3. Impossible to align backend data constraints and error messages with the on the client 4. Accept server side validations exist always and how to reconcile them
2. Poor styling support and no control over markup 3. Impossible to align backend data constraints and error messages with the on the client 4. Accept server side validations exist always and how to reconcile them
2. Poor styling support and no control over markup 3. Impossible to align backend data constraints and error messages with the on the client 4. Accept server side validations exist always and how to reconcile them
2. Poor styling support and no control over markup 3. Impossible to align backend data constraints and error messages with the on the client 4. Accept server side validations exist always and how to reconcile them