UNPKG

smartystreets-javascript-sdk

Version:
2 lines (1 loc) 1.58 kB
import{__require as e}from"../Errors.mjs";var t,i;function r(){if(i)return t;i=1;const r=e().UnprocessableEntityError,s="Country field is required.",o="Either freeform or address1 is required.",n="Insufficient information: One or more required fields were not set on the lookup.",a="Invalid input: geocode can only be set to 'true' (default is 'false'.",u="Invalid input: language can only be set to 'latin' or 'native'. When not set, the the output language will match the language of the input values.";function h(e){if(!e)return!0;return e.replace(/\s/g,"").length<1}function d(e){return!h(e)}return t=class{constructor(e,t){this.result=[],this.country=e,this.freeform=t,this.address1=void 0,this.address2=void 0,this.address3=void 0,this.address4=void 0,this.organization=void 0,this.locality=void 0,this.administrativeArea=void 0,this.postalCode=void 0,this.geocode=void 0,this.language=void 0,this.inputId=void 0,this.ensureEnoughInfo=this.ensureEnoughInfo.bind(this),this.ensureValidData=this.ensureValidData.bind(this),this.customParameters={}}addCustomParameter(e,t){this.customParameters[e]=t}ensureEnoughInfo(){if(h(this.country))throw new r(s);if(d(this.freeform))return!0;if(h(this.address1))throw new r(o);if(d(this.postalCode))return!0;if(h(this.locality)||h(this.administrativeArea))throw new r(n);return!0}ensureValidData(){if((()=>d(this.geocode)&&"true"!==this.geocode.toLowerCase())())throw new r(a);if((()=>{let e=e=>this.language.toLowerCase()===e;return d(this.language)&&!(e("latin")||e("native"))})())throw new r(u);return!0}}}export{r as __require};