Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🔎 Overview
The meta tags API wasn't updated or revised since v2 releases. Here are the various problems I see with it:
valid
vspassed
andinvalid
vsfailed
changed
) which will make immutable fields with arrays or objects as values impossible to be accurate.valid
flag, you can always check error messages as an alternativeopposite flags
The new API removes a bunch of flags:
untouched
,pristine
,invalid
,passed
,failed
,validated
, andchanged
. All of these flags information can be inferred from their opposite one and a combination of one or more.Combined flags
For example, the
passed
flag is justdirty
andvalid
,changed
is a simple comparison of the initial value and current value. And for complex fields, you can use 3rd party libraries for recursive comparisons.valid
flagAlso, there is the topic of the initial
valid
flag, the problem with this flag is that it is confusing to use. I've found myself using the error message to check if a field is valid or not rather thanvalid
. Because initially, you could have an invalid field but since no validation was done it is impossible to tell.So we actually have 3 states,
false
,true
, andundefined
as in we don't know yet. This is also problematic becauseundefined
andfalse
work pretty much the same as they are both falsy values. So introducingundefined
like inv2
will be very confusing.So checking for error messages works for all purposes of the naive
valid
flag.I'm now considering between removing the
valid
flag completely and changing its behavior to work likepassed
to make it more accurate, but that would make the two statesfalse
andundefined
both asfalse
so users of the library must be aware of that caveat.