-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1177 from CruGlobal/8145-optional-street-address
[MPDX-8145] Make address street optional
- Loading branch information
Showing
7 changed files
with
117 additions
and
59 deletions.
There are no files selected for viewing
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
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
19 changes: 0 additions & 19 deletions
19
.../Contacts/ContactDetails/ContactDetailsTab/Mailing/AddAddressModal/createAddressSchema.ts
This file was deleted.
Oops, something went wrong.
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
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
20 changes: 0 additions & 20 deletions
20
...s/ContactDetails/ContactDetailsTab/Mailing/EditContactAddressModal/updateAddressSchema.ts
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
src/components/Contacts/ContactDetails/ContactDetailsTab/Mailing/addressSchema.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import * as yup from 'yup'; | ||
|
||
export const addressSchema = yup.object({ | ||
city: yup.string().nullable(), | ||
country: yup.string().nullable(), | ||
historic: yup.boolean().nullable(), | ||
location: yup.string().nullable(), | ||
metroArea: yup.string().nullable(), | ||
postalCode: yup.string().nullable(), | ||
region: yup.string().nullable(), | ||
state: yup.string().nullable(), | ||
// Formik ignores test functions defined at the object-level, so this needs to be defined on a | ||
// specific field. It doesn't matter which field. | ||
street: yup | ||
.string() | ||
.nullable() | ||
.test( | ||
'one-field', | ||
() => 'At least one address field must be filled out', | ||
(value, { parent: address }) => | ||
Boolean( | ||
address.city || | ||
address.country || | ||
address.metroArea || | ||
address.postalCode || | ||
address.region || | ||
address.state || | ||
address.street, | ||
), | ||
), | ||
primaryMailingAddress: yup.boolean().nullable(false), | ||
}); | ||
|
||
export type AddressSchema = yup.InferType<typeof addressSchema>; |