{"version":3,"sources":["../../src/structs/Address.ts"],"sourcesContent":["import { isEmpty, text, required, valid, Struct } from '@thisisagile/easy';\nimport { Country } from '../enums/Country';\nimport { postalCode } from '../values/PostalCode';\n\nexport class Address extends Struct {\n  @required() readonly street = this.state.street as string;\n  @required() readonly houseNumber = this.state.houseNumber as string;\n  readonly extension = this.state.extension as string;\n  @valid() readonly postalCode = postalCode(this.state.postalCode, this.state.country);\n  @required() readonly city = this.state.city as string;\n  @required() readonly country = Country.byId<Country>(this.state.country);\n\n  toString(): string {\n    return text(this.street)\n      .with(' ', this.houseNumber, this.extension)\n      .with(', ', text(this.postalCode).with(' ', this.city, this.country?.name))\n      .toString();\n  }\n}\n\nexport const isAddress = (a?: unknown): a is Address => {\n  return !isEmpty(a) && a instanceof Address;\n};\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,SAAS,MAAM,UAAU,OAAO,cAAc;AAIhD,IAAM,UAAN,cAAsB,OAAO;AAAA,EACb,SAAS,KAAK,MAAM;AAAA,EACpB,cAAc,KAAK,MAAM;AAAA,EACrC,YAAY,KAAK,MAAM;AAAA,EACd,aAAa,WAAW,KAAK,MAAM,YAAY,KAAK,MAAM,OAAO;AAAA,EAC9D,OAAO,KAAK,MAAM;AAAA,EAClB,UAAU,QAAQ,KAAc,KAAK,MAAM,OAAO;AAAA,EAEvE,WAAmB;AACjB,WAAO,KAAK,KAAK,MAAM,EACpB,KAAK,KAAK,KAAK,aAAa,KAAK,SAAS,EAC1C,KAAK,MAAM,KAAK,KAAK,UAAU,EAAE,KAAK,KAAK,KAAK,MAAM,KAAK,SAAS,IAAI,CAAC,EACzE,SAAS;AAAA,EACd;AACF;AAbuB;AAAA,EAApB,SAAS;AAAA,GADC,QACU;AACA;AAAA,EAApB,SAAS;AAAA,GAFC,QAEU;AAEH;AAAA,EAAjB,MAAM;AAAA,GAJI,QAIO;AACG;AAAA,EAApB,SAAS;AAAA,GALC,QAKU;AACA;AAAA,EAApB,SAAS;AAAA,GANC,QAMU;AAUhB,IAAM,YAAY,CAAC,MAA8B;AACtD,SAAO,CAAC,QAAQ,CAAC,KAAK,aAAa;AACrC;","names":[]}