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