@bcrs-shared-components/base-address 2.2.1 → 2.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BaseAddress.vue +10 -2
- package/package.json +3 -2
package/BaseAddress.vue
CHANGED
|
@@ -165,6 +165,7 @@ import { Validations } from 'vuelidate-property-decorators'
|
|
|
165
165
|
import { uniqueId } from 'lodash'
|
|
166
166
|
import { ValidationMixin, CountriesProvincesMixin } from '@bcrs-shared-components/mixins'
|
|
167
167
|
import { FormIF } from '@bcrs-shared-components/interfaces'
|
|
168
|
+
import { isPostalCodeOptionalForCountry } from '@bcrs-shared-components/validators'
|
|
168
169
|
|
|
169
170
|
/**
|
|
170
171
|
* The component for displaying and editing an address.
|
|
@@ -335,7 +336,14 @@ export default class BaseAddress extends Mixins(ValidationMixin, CountriesProvin
|
|
|
335
336
|
} else {
|
|
336
337
|
label = 'Postal Code'
|
|
337
338
|
}
|
|
338
|
-
|
|
339
|
+
|
|
340
|
+
let isRequired = this.isSchemaRequired('postalCode')
|
|
341
|
+
// If schema uses isRequiredPostalCode validator, check if country requires postal codes
|
|
342
|
+
if (!isRequired && this.schemaLocal?.postalCode?.isRequiredPostalCode) {
|
|
343
|
+
isRequired = !isPostalCodeOptionalForCountry(this.addressCountry)
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
return label + (isRequired ? '' : ' (Optional)')
|
|
339
347
|
}
|
|
340
348
|
|
|
341
349
|
/** The Address Country label with 'optional' as needed. */
|
|
@@ -358,7 +366,7 @@ export default class BaseAddress extends Mixins(ValidationMixin, CountriesProvin
|
|
|
358
366
|
|
|
359
367
|
/** Whether the specified prop is required according to the schema. */
|
|
360
368
|
isSchemaRequired (prop: string): boolean {
|
|
361
|
-
return Boolean(this.schemaLocal
|
|
369
|
+
return Boolean(this.schemaLocal?.[prop]?.required)
|
|
362
370
|
}
|
|
363
371
|
|
|
364
372
|
/** Array of validation rules used by input elements to prevent extra whitespace. */
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bcrs-shared-components/base-address",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@bcrs-shared-components/mixins": "^1.2.6",
|
|
9
|
+
"@bcrs-shared-components/validators": "^1.0.2",
|
|
9
10
|
"lodash.uniqueid": "^4.0.1",
|
|
10
11
|
"vue": "^2.7.14",
|
|
11
12
|
"vuelidate": "0.6.2"
|
|
@@ -14,5 +15,5 @@
|
|
|
14
15
|
"vue-property-decorator": "^9.1.2",
|
|
15
16
|
"vuelidate-property-decorators": "1.0.28"
|
|
16
17
|
},
|
|
17
|
-
"gitHead": "
|
|
18
|
+
"gitHead": "866721c2c03c110aa873d9435bcf1660c279fe4a"
|
|
18
19
|
}
|