Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow access to Address Formats? #72

Open
recipher opened this issue Oct 23, 2023 · 0 comments
Open

Allow access to Address Formats? #72

recipher opened this issue Oct 23, 2023 · 0 comments
Assignees
Labels
feature New feature or request

Comments

@recipher
Copy link

recipher commented Oct 23, 2023

Hi. Great library, much appreciate the work that has gone into it.

I'm using the library in the "expected" mode, to render addresses, but I'm also attempting to use the configuration to render address forms, based on a country. So, for example, if someone is from Japan, then the address input form should match the format from address-formats.ts, here...

I had tried to do this by just setting all of the setters, like this:

    const address = new PostalAddress();
    address
      .setDo("do")
      .setDong("dong")
      .setGu("gu")
      .setSi("si")
      .setAddress1("address1")
      .setAddress2("address2")
      .setCity("city")
      .setRegion("region")
      .setProvince("province")
      .setPrefecture("prefecture")
      .setPostalCode("postalCode")
      .setState("state")
      .setRepublic("republic")
      .setFormat({ country, useTransforms: false });

    return address.toArray();

And then using the array format to determine which fields to display. Obviously, not what the library is designed for, but the address format information is very useful in this mode. However, because this code here...

public setAddress1(newValue: string): this {

clashes with

public setDong(newValue: string): this {

Because setAddress1 and setDong both get set at the same time, I can't effectively use this (admittedly hacky) method to get the address format, because it matters which set method I call first.

However, if the address formats were available from the PostalAddress object, e.g. .getFormat({ country: 'KR', type: 'personal' }), then that would be super useful to me.

Any chance? Should I raise a PR?

Thanks, Johnny

@joaocarmo joaocarmo self-assigned this Nov 23, 2023
@joaocarmo joaocarmo added the feature New feature or request label Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants