first-npm-package-nicule
Version:
This isi first npm package
14 lines (11 loc) • 488 B
text/typescript
export function valuesMatch(firstName, ...fieldNames: Array<string>): (formData) => any | undefined {
return formData => {
const doNotMatch = [firstName, ...fieldNames].some(fieldName => {
return fieldNames.some(fieldToCompare => formData[fieldToCompare] !== formData[fieldName]);
});
if (!doNotMatch || [undefined, ''].includes(formData[firstName])) {
return undefined;
}
return { doNotMatch };
};
}