You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 9, 2022. It is now read-only.
Vally isn't even a week old and I am already thinking about a rewrite 😅
I want vally to become more functional and flexible. So DOM-manipulation should be deferred to the user as much as possible (apart from makeValidationWithBindings). Here are a few thoughts on how to achieve this:
Instead of handing selector strings for fields, we could directly use the HTMLInputElements
The validation itself could be promise based and return an array of failed fields (more on that below)
Validators become an object instead of a single function
That way the user is in charge of how to handle and react to each individual field change (#22 would be no longer necessary) :
Example
constmyNameInput=document.getElementById('js-name-input')vally.validate([{field: myNameInput,validators: [{type: 'isNotEmpty',msg: 'Please enter a name.',fn: isNotEmpty},]}]).then((results)=>{results.forEach(res=>{/* user does something in response */})})
Another advantage of this approach would be, that because we already get the nodes to validate
we can now merge validators, that run on the same node ( #19 ).
One problem with the promise-based approach would be, that whis would not work in IE by default.
The text was updated successfully, but these errors were encountered:
The more I think about it we probably do not even need promises here.
Simply returning the results array would do the trick. The user can then do whatever he/she wants with it.
Living on the fastlane.
Vally isn't even a week old and I am already thinking about a rewrite 😅
I want vally to become more functional and flexible. So DOM-manipulation should be deferred to the user as much as possible (apart from
makeValidationWithBindings
). Here are a few thoughts on how to achieve this:When iterating over a fields validators we can then resolve the promise with the following content
That way the user is in charge of how to handle and react to each individual field change (#22 would be no longer necessary) :
Example
Another advantage of this approach would be, that because we already get the nodes to validate
we can now merge validators, that run on the same node ( #19 ).
One problem with the promise-based approach would be, that whis would not work in IE by default.
The text was updated successfully, but these errors were encountered: