Open sourcegr opened 4 years ago
You may want to keep it simple, and this is fully understood. The truth is that most of the tooling provided by this PR can be accomplished from the outside.
But since on 99% of the occasions a check is required in order to validate the contents for a field, it feels a little overhead to do it again and again all over, setting and unsetting error messages in the code.
Hello @vikignt !
The Textfield component was kind of buggy, at least in our workflow.
error
prop was present, it would show no matter what.error
prop was present, even when the required field was set and the input was filled, the error would still persist.With this PR, the following things happen, hopefully setting some things straight and making it more a component than a display.
validator
callback to check the value of the component against, and set theinvalid
flag on it when false is returned.error
is not displayed, unless the component value is actually invalid (invalid is - for example - an empty string when therequired
is set, or a value that fails thevalidator
callback.)We also believe that the default value for
messagePersist
should change totrue
- since we always - always - have to fill this up. I would like to hear what other users think on this.