profile
viewpoint

Ask questionsComparing Fields

I'm working on a fairly straightforward problem, comparing a password to a confirmation field. I have found a prior issue, however the answers provided appear out-of-date and in reference to long-gone APIs. I was able to effect a solution, however I'm not quite sure if this is the right approach and if there are errors lurking:

Note: I have based the parameter names on information in the aforementioned answers, but I cannot find a definitive API definition for the define method in the documentation so I'm not sure if those are correct.

export const match = (field) => define('match', (value, { branch, path }) => {
        if (branch[0][field] === value) {
                return true;
        } else {
                return false;
        }
});
ianstormtaylor/superstruct

Answer questions RWOverdijk

if (branch[0][field] === value) {
  return true;
} else {
  return false;
}

I don't know the answer but I can point out injustices when I see them. Don't do this ☝️ Instead just 👇

return branch[0][field] === value;

useful!

Related questions

How to validate dependent fields? hot 6
source:https://uonfu.com/
Github User Rank List