Last active
July 7, 2022 21:26
-
-
Save john-raymon/7897c797c1d9671631253f9bb327e900 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
otherPropertyAddresses: mixed().when('numOtherProperties', () => { | |
return array().of( | |
addressValidator(true).test( | |
'is-address-matching', | |
'Address must not match rental property address', | |
(value, options) => { | |
const { numRentalProperties, rentalPropertyAddresses } = options.from[1].value; | |
const { address: otherAddress, city: otherCity, state: otherState, zip: otherZip } = value; | |
const hasAmatch = numRentalProperties && rentalPropertyAddresses.some(({ address = '', city = '', state = '', zip = '' }) => { | |
return (otherAddress === address && otherCity === city && otherState === state && otherZip === zip); | |
}); | |
// if hasAMatch is true then fail test | |
return !hasAMatch; | |
} | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Below you can see the changes I made that resulted in the code above