taxtank-core 0.30.0 → 0.30.1

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.
@@ -4,7 +4,7 @@ import * as i1$2 from '@angular/common';
4
4
  import { CommonModule, DatePipe } from '@angular/common';
5
5
  import * as i1 from '@angular/common/http';
6
6
  import { HttpParams, HttpErrorResponse, HTTP_INTERCEPTORS } from '@angular/common/http';
7
- import { map, mergeMap, filter, catchError, take, switchMap, finalize, first as first$1, skip, distinctUntilChanged, debounceTime } from 'rxjs/operators';
7
+ import { map, mergeMap, filter, catchError, take, switchMap, finalize, first as first$1, skip, debounceTime, distinctUntilChanged } from 'rxjs/operators';
8
8
  import { ReplaySubject, Subject, BehaviorSubject, throwError, Observable, of, combineLatest, forkJoin, from, merge as merge$1 } from 'rxjs';
9
9
  import { plainToClass, Type, Exclude, Transform, Expose, classToPlain } from 'class-transformer';
10
10
  import { JwtHelperService } from '@auth0/angular-jwt';
@@ -15877,187 +15877,19 @@ class AbstractForm extends UntypedFormGroup {
15877
15877
  }
15878
15878
  }
15879
15879
 
15880
- /**
15881
- * Check if at least one form field is true, otherwise form is invalid.
15882
- * Use with groups of boolean form controls (checkbox, toggle, etc.)
15883
- */
15884
- function atLeastOneCheckedValidator() {
15885
- return (formGroup) => {
15886
- return Object.values(formGroup.controls)
15887
- .find((control) => control.value) ? null : { nothingChecked: true };
15888
- };
15889
- }
15890
-
15891
- /**
15892
- * Validation function for autocomplete fields. Checks that the user should select a value from a list rather than type in input field
15893
- * @TODO Alex: create class AppValidators with static methods and move there all custom validators (line Angular Validators)
15894
- */
15895
- function autocompleteValidator() {
15896
- return (control) => {
15897
- return (!control.value || (typeof control.value === 'object')) ? null : { notFromList: true };
15898
- };
15899
- }
15900
-
15901
- function conditionalValidator(condition, validator) {
15902
- return function (control) {
15903
- revalidateOnChanges(control);
15904
- if (control && control.parent) {
15905
- if (condition(control.parent)) {
15906
- return validator(control);
15907
- }
15908
- }
15909
- return null;
15910
- };
15911
- }
15912
- /**
15913
- * Conditional validator depends on other fields and should be updated on each form value change
15914
- */
15915
- function revalidateOnChanges(control) {
15916
- if (control && control.parent && !control['_revalidateOnChanges']) {
15917
- control['_revalidateOnChanges'] = true;
15918
- control.parent.valueChanges.pipe(distinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)))
15919
- .subscribe(() => {
15920
- control.updateValueAndValidity({ emitEvent: false });
15921
- });
15922
- }
15923
- return;
15924
- }
15925
-
15926
- /**
15927
- * Regular expressions that are used to check password strength and valid values
15928
- */
15929
- const PASSWORD_REGEXPS = {
15930
- medium: /(((?=.*[a-z])(?=.*[A-Z]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[A-Z])(?=.*[0-9])))(?=.{6,})/,
15931
- strong: /(((?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*]))|((?=.*[a-z])(?=.*[0-9])(?=.*[!@#$%^&*]))|((?=.*[A-Z])(?=.*[0-9]))(?=.*[!@#$%^&*]))(?=.{8,})/,
15932
- format: /^[0-9a-zA-Z!@$!%*?&#]*$/
15933
- };
15934
- function passwordValidator() {
15935
- return (control) => {
15936
- if (!PASSWORD_REGEXPS.format.test(control.value)) {
15937
- return { passwordInvalid: true };
15938
- }
15939
- if (!PASSWORD_REGEXPS.medium.test(control.value)) {
15940
- return { passwordWeak: true };
15941
- }
15942
- return null;
15943
- };
15944
- }
15945
-
15946
- function passwordMatchValidator(newPassControlName, confirmPassControlName) {
15947
- return (group) => {
15948
- const passwordControl = group.get(newPassControlName);
15949
- const confirmControl = group.get(confirmPassControlName);
15950
- if (confirmControl.errors && !confirmControl.hasError('passwordMismatch')) {
15951
- // return if another validator has already found an error on the confirmControl
15952
- return this;
15953
- }
15954
- if (passwordControl.value !== confirmControl.value) {
15955
- confirmControl.setErrors({ passwordMismatch: true });
15956
- }
15957
- else {
15958
- confirmControl.setErrors(null);
15959
- }
15960
- };
15961
- }
15962
-
15963
- var MessagesEnum$1;
15964
- (function (MessagesEnum) {
15965
- MessagesEnum["INVALID_DATE"] = "The date should not be before $1";
15966
- })(MessagesEnum$1 || (MessagesEnum$1 = {}));
15967
-
15968
- /**
15969
- * Validation function, that checks If date form value is more than provided date
15970
- */
15971
- function minDateValidator(date, message = MessagesEnum$1.INVALID_DATE.replace('$1', new DatePipe('en-US').transform(date))) {
15972
- return (control) => {
15973
- if (!control.value) {
15974
- return null;
15975
- }
15976
- // form control value can be as a Moment object - we wrap it in "new Date()" to work with it like with JS Date
15977
- if (new Date(control.value) >= new Date(date)) {
15978
- return null;
15979
- }
15980
- return { minDate: message };
15981
- };
15982
- }
15983
-
15984
- /**
15985
- * Validator that check if sum amount of provided fields is greater than provided sum
15986
- * @param field to check in each formArray element
15987
- * @param summary to compare with fields sum
15988
- * @param fieldAlias to show it in error message
15989
- */
15990
- function fieldsSumValidator(field, summary = 100, fieldAlias) {
15991
- return (formArray) => {
15992
- // calculate sum of desired fields in formArray control
15993
- const fieldsSum = formArray['controls']
15994
- .reduce((acc, group) => acc += group.get(field).value, 0);
15995
- if (fieldsSum <= summary) {
15996
- return null;
15997
- }
15998
- else {
15999
- return {
16000
- fieldsSum: {
16001
- name: field,
16002
- alias: fieldAlias,
16003
- summary
16004
- }
16005
- };
16006
- }
16007
- };
16008
- }
16009
-
16010
- /**
16011
- * Validation function, that checks If provided date is within a current financial year
16012
- */
16013
- function currentFinYearValidator() {
16014
- const currentFinYear = new FinancialYear();
16015
- return (control) => {
16016
- if (!control.value || control.value >= currentFinYear.startDate && control.value <= currentFinYear.endDate) {
16017
- return null;
16018
- }
16019
- return { notCurrentFinYear: true };
16020
- };
16021
- }
16022
-
16023
- const MAX_SIZE = 4194304;
16024
- class FileValidator {
16025
- // File max size check
16026
- static fileMaxSize(maxSize = MAX_SIZE) {
16027
- const validatorFn = (file) => {
16028
- return file.size > maxSize ? { fileMaxSize: { maxSize } } : null;
16029
- };
16030
- return FileValidator.fileValidation(validatorFn);
16031
- }
16032
- // File extension check
16033
- static fileExtensions(allowedExtensions = DOCUMENT_FILE_TYPES.all) {
16034
- const validatorFn = (file) => {
16035
- return allowedExtensions.includes(file.type) ? null : { fileExtension: { allowedExtensions: allowedExtensions.join() } };
16036
- };
16037
- return FileValidator.fileValidation(validatorFn);
16038
- }
16039
- static fileValidation(validatorFn) {
16040
- return (formControl) => {
16041
- if (!formControl.value) {
16042
- return null;
16043
- }
16044
- return validatorFn(formControl.value);
16045
- };
16046
- }
16047
- }
16048
-
16049
15880
  /**
16050
15881
  * Validator for address, check if corelogic suggestion selected correctly
16051
15882
  */
16052
15883
  function addressCorelogicValidator() {
16053
15884
  return (form) => {
16054
- if (form.isCorelogicRequired) {
16055
- if (form.get('corelogicLocId').hasError('required')) {
16056
- return { address: 'Street, city, state or postal code not specified' };
16057
- }
16058
- if (form.get('corelogicRefId').hasError('required')) {
16059
- return { address: 'Unit/House number not specified' };
16060
- }
15885
+ // we are interested in corelogic ids only for Australian addresses
15886
+ if (!form.isAustraliaSelected()) {
15887
+ return null;
15888
+ }
15889
+ // we need at least corelogic locality id to get growth percent
15890
+ const locIdControl = form.get('corelogicLocId');
15891
+ if (locIdControl.enabled && locIdControl.hasError('required')) {
15892
+ return { address: 'City, state or postal code not specified' };
16061
15893
  }
16062
15894
  return null;
16063
15895
  };
@@ -16067,51 +15899,49 @@ function addressCorelogicValidator() {
16067
15899
  * Address form. Works with corelogic or manual address
16068
15900
  */
16069
15901
  class AddressForm extends AbstractForm {
16070
- /**
16071
- * @param address instance which should be created/edited
16072
- * @param isCorelogicRequired for example, for property we need corelogic location even for manual address,
16073
- * so we have to search corelogic location based on manual fields values
16074
- */
16075
- constructor(address = plainToClass(Address, {}), isCorelogicRequired = false) {
15902
+ constructor(
15903
+ // no default value because Address form is always a child form. That's mean address value always passed and then default value never work.
15904
+ // even if null passed, default value will not work
15905
+ address) {
16076
15906
  super({
16077
15907
  // prefill search input with address string for edit case
16078
- searchQuery: new UntypedFormControl(address.address ? address.nameLong : null, Validators.required),
16079
- type: new UntypedFormControl(address.type | AddressTypeEnum.STREET, Validators.required),
16080
- // Corelogic fields
16081
- corelogicLocId: new UntypedFormControl(address.corelogicLocId),
16082
- corelogicRefId: new UntypedFormControl(address.corelogicRefId),
16083
- // manual fields
16084
- unitNumber: new UntypedFormControl({ value: address.unitNumber, disabled: true }),
16085
- address: new UntypedFormControl({ value: address.address, disabled: true }, Validators.required),
16086
- streetNumber: new UntypedFormControl({ value: address.streetNumber, disabled: true }, [Validators.required, Validators.pattern(AddressForm.streetNumberPattern)]),
16087
- street: new UntypedFormControl({ value: address.street, disabled: true }, Validators.required),
16088
- city: new UntypedFormControl({ value: address.city, disabled: true }, Validators.required),
16089
- state: new UntypedFormControl({ value: address.state, disabled: true }, Validators.required),
16090
- postcode: new UntypedFormControl({ value: address.postcode, disabled: true }, Validators.required),
16091
- country: new UntypedFormControl({ value: address.country || Country.australia, disabled: true }, conditionalValidator(() => !isCorelogicRequired, Validators.required))
15908
+ searchQuery: new UntypedFormControl((address === null || address === void 0 ? void 0 : address.address) ? address.nameLong : null, Validators.required),
15909
+ type: new UntypedFormControl((address === null || address === void 0 ? void 0 : address.type) || AddressTypeEnum.STREET, Validators.required),
15910
+ // corelogic fields (required for Australia and disabled for other countries)
15911
+ corelogicLocId: new UntypedFormControl({ value: address === null || address === void 0 ? void 0 : address.corelogicLocId, disabled: true }, Validators.required),
15912
+ corelogicRefId: new UntypedFormControl({ value: address === null || address === void 0 ? void 0 : address.corelogicRefId, disabled: true }),
15913
+ // manual fields (using when address not found in corelogic)
15914
+ unitNumber: new UntypedFormControl({ value: address === null || address === void 0 ? void 0 : address.unitNumber, disabled: true }),
15915
+ address: new UntypedFormControl({ value: address === null || address === void 0 ? void 0 : address.address, disabled: true }, Validators.required),
15916
+ streetNumber: new UntypedFormControl({ value: address === null || address === void 0 ? void 0 : address.streetNumber, disabled: true }, [Validators.required, Validators.pattern(AddressForm.streetNumberPattern)]),
15917
+ street: new UntypedFormControl({ value: address === null || address === void 0 ? void 0 : address.street, disabled: true }, Validators.required),
15918
+ city: new UntypedFormControl({ value: address === null || address === void 0 ? void 0 : address.city, disabled: true }, Validators.required),
15919
+ state: new UntypedFormControl({ value: address === null || address === void 0 ? void 0 : address.state, disabled: true }, Validators.required),
15920
+ postcode: new UntypedFormControl({ value: address === null || address === void 0 ? void 0 : address.postcode, disabled: true }, Validators.required),
15921
+ country: new UntypedFormControl({ value: (address === null || address === void 0 ? void 0 : address.country) || Country.australia, disabled: true }, Validators.required)
16092
15922
  }, address, addressCorelogicValidator());
16093
- this.isCorelogicRequired = isCorelogicRequired;
16094
15923
  /**
16095
15924
  * Emit event to search address in corelogic when user filled enough data for corelogic
16096
15925
  */
16097
15926
  this.onSearch = new EventEmitter();
15927
+ if (this.isAustraliaSelected()) {
15928
+ this.enableCorelogicFields();
15929
+ }
16098
15930
  this.listenEvents();
16099
15931
  }
16100
15932
  /**
16101
15933
  * Get search query for corelogic location search based on manual fields values
16102
15934
  */
16103
15935
  get manualSearchQuery() {
16104
- if (!this.isManualSearchAvailable()) {
15936
+ // nothing to search when manual fields are invalid or when selected country is not Australia because we don't need to use corelogic for other countries
15937
+ if (!this.isManualSearchAvailable() || !this.isAustraliaSelected()) {
16105
15938
  return '';
16106
15939
  }
16107
- return this.currentValue.nameLong;
15940
+ // for manual mode we search corelogic for city (location) and ignore street
15941
+ return `${this.get('city').value} ${this.get('state').value} ${this.get('postcode').value}`;
16108
15942
  }
16109
15943
  listenEvents() {
16110
15944
  this.listenSearchQueryChanges();
16111
- // no need to search corelogic locality when corelogic is not required
16112
- if (this.isCorelogicRequired) {
16113
- this.listenManualFieldsChanges();
16114
- }
16115
15945
  }
16116
15946
  /**
16117
15947
  * Handle corelogic suggestion select
@@ -16127,25 +15957,30 @@ class AddressForm extends AbstractForm {
16127
15957
  corelogicRefId: suggestion.propertyId
16128
15958
  });
16129
15959
  }
15960
+ /**
15961
+ * Check if Australia is selected in country field
15962
+ */
15963
+ isAustraliaSelected() {
15964
+ var _a;
15965
+ return ((_a = this.get('country').value) === null || _a === void 0 ? void 0 : _a.id) === Country.australia.id;
15966
+ }
16130
15967
  /**
16131
15968
  * Enable manual mode
16132
15969
  */
16133
15970
  switchToManual() {
16134
15971
  this.isManual = true;
16135
15972
  this.get('searchQuery').disable();
15973
+ this.get('unitNumber').enable();
16136
15974
  this.get('address').enable();
16137
15975
  this.get('streetNumber').enable();
16138
15976
  this.get('street').enable();
16139
- this.get('unitNumber').enable();
16140
15977
  this.get('city').enable();
16141
15978
  this.get('state').enable();
16142
15979
  this.get('postcode').enable();
16143
- if (!this.isCorelogicRequired) {
16144
- this.get('country').enable();
16145
- this.get('corelogicLocId').disable();
16146
- this.get('corelogicRefId').disable();
16147
- }
15980
+ this.get('country').enable();
15981
+ this.listenManualFieldsChanges();
16148
15982
  this.listenStreetFieldsChanges();
15983
+ this.listenCountryChanges();
16149
15984
  }
16150
15985
  /**
16151
15986
  * Emit event to search address in corelogic when search field changes
@@ -16177,7 +16012,7 @@ class AddressForm extends AbstractForm {
16177
16012
  * Check if all fields required for manual corelogic search are filled before request sending
16178
16013
  */
16179
16014
  isManualSearchAvailable() {
16180
- return this.get('address').valid && this.get('city').valid && this.get('state').valid && this.get('postcode').valid;
16015
+ return this.get('city').valid && this.get('state').valid && this.get('postcode').valid;
16181
16016
  }
16182
16017
  /**
16183
16018
  * When corelogic is required we have to search address even for manual address
@@ -16189,7 +16024,7 @@ class AddressForm extends AbstractForm {
16189
16024
  // delay to avoid search request for each value change
16190
16025
  debounceTime(AddressForm.searchDelay),
16191
16026
  // do nothing when not all required fields filled
16192
- filter(() => this.isManualSearchAvailable()), map(() => this.manualSearchQuery),
16027
+ filter(() => this.isManualSearchAvailable() && this.isAustraliaSelected()), map(() => this.manualSearchQuery),
16193
16028
  // skip when value not changed
16194
16029
  distinctUntilChanged())
16195
16030
  .subscribe(() => {
@@ -16207,6 +16042,26 @@ class AddressForm extends AbstractForm {
16207
16042
  this.get('address').setValue(`${this.get('streetNumber').value} ${this.get('street').value}`);
16208
16043
  });
16209
16044
  }
16045
+ enableCorelogicFields() {
16046
+ this.get('corelogicLocId').enable();
16047
+ this.get('corelogicRefId').enable();
16048
+ }
16049
+ disableCorelogicFields() {
16050
+ this.get('corelogicLocId').disable();
16051
+ this.get('corelogicRefId').disable();
16052
+ }
16053
+ /**
16054
+ * Corelogic loc id is required for Australian addresses
16055
+ */
16056
+ listenCountryChanges() {
16057
+ this.get('country').valueChanges.subscribe(() => {
16058
+ if (this.isAustraliaSelected()) {
16059
+ this.enableCorelogicFields();
16060
+ return;
16061
+ }
16062
+ this.disableCorelogicFields();
16063
+ });
16064
+ }
16210
16065
  }
16211
16066
  /**
16212
16067
  * Min search query required length
@@ -16302,6 +16157,175 @@ class LoanForm extends AbstractForm {
16302
16157
  }
16303
16158
  LoanForm.mortgageLoanTypes = [LoanTypeEnum.MORTGAGE, LoanTypeEnum.HOME_EQUITY_LINE_OF_CREDIT, LoanTypeEnum.HOME_LOAN];
16304
16159
 
16160
+ /**
16161
+ * Check if at least one form field is true, otherwise form is invalid.
16162
+ * Use with groups of boolean form controls (checkbox, toggle, etc.)
16163
+ */
16164
+ function atLeastOneCheckedValidator() {
16165
+ return (formGroup) => {
16166
+ return Object.values(formGroup.controls)
16167
+ .find((control) => control.value) ? null : { nothingChecked: true };
16168
+ };
16169
+ }
16170
+
16171
+ /**
16172
+ * Validation function for autocomplete fields. Checks that the user should select a value from a list rather than type in input field
16173
+ * @TODO Alex: create class AppValidators with static methods and move there all custom validators (line Angular Validators)
16174
+ */
16175
+ function autocompleteValidator() {
16176
+ return (control) => {
16177
+ return (!control.value || (typeof control.value === 'object')) ? null : { notFromList: true };
16178
+ };
16179
+ }
16180
+
16181
+ function conditionalValidator(condition, validator) {
16182
+ return function (control) {
16183
+ revalidateOnChanges(control);
16184
+ if (control && control.parent) {
16185
+ if (condition(control.parent)) {
16186
+ return validator(control);
16187
+ }
16188
+ }
16189
+ return null;
16190
+ };
16191
+ }
16192
+ /**
16193
+ * Conditional validator depends on other fields and should be updated on each form value change
16194
+ */
16195
+ function revalidateOnChanges(control) {
16196
+ if (control && control.parent && !control['_revalidateOnChanges']) {
16197
+ control['_revalidateOnChanges'] = true;
16198
+ control.parent.valueChanges.pipe(distinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)))
16199
+ .subscribe(() => {
16200
+ control.updateValueAndValidity({ emitEvent: false });
16201
+ });
16202
+ }
16203
+ return;
16204
+ }
16205
+
16206
+ /**
16207
+ * Regular expressions that are used to check password strength and valid values
16208
+ */
16209
+ const PASSWORD_REGEXPS = {
16210
+ medium: /(((?=.*[a-z])(?=.*[A-Z]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[A-Z])(?=.*[0-9])))(?=.{6,})/,
16211
+ strong: /(((?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*]))|((?=.*[a-z])(?=.*[0-9])(?=.*[!@#$%^&*]))|((?=.*[A-Z])(?=.*[0-9]))(?=.*[!@#$%^&*]))(?=.{8,})/,
16212
+ format: /^[0-9a-zA-Z!@$!%*?&#]*$/
16213
+ };
16214
+ function passwordValidator() {
16215
+ return (control) => {
16216
+ if (!PASSWORD_REGEXPS.format.test(control.value)) {
16217
+ return { passwordInvalid: true };
16218
+ }
16219
+ if (!PASSWORD_REGEXPS.medium.test(control.value)) {
16220
+ return { passwordWeak: true };
16221
+ }
16222
+ return null;
16223
+ };
16224
+ }
16225
+
16226
+ function passwordMatchValidator(newPassControlName, confirmPassControlName) {
16227
+ return (group) => {
16228
+ const passwordControl = group.get(newPassControlName);
16229
+ const confirmControl = group.get(confirmPassControlName);
16230
+ if (confirmControl.errors && !confirmControl.hasError('passwordMismatch')) {
16231
+ // return if another validator has already found an error on the confirmControl
16232
+ return this;
16233
+ }
16234
+ if (passwordControl.value !== confirmControl.value) {
16235
+ confirmControl.setErrors({ passwordMismatch: true });
16236
+ }
16237
+ else {
16238
+ confirmControl.setErrors(null);
16239
+ }
16240
+ };
16241
+ }
16242
+
16243
+ var MessagesEnum$1;
16244
+ (function (MessagesEnum) {
16245
+ MessagesEnum["INVALID_DATE"] = "The date should not be before $1";
16246
+ })(MessagesEnum$1 || (MessagesEnum$1 = {}));
16247
+
16248
+ /**
16249
+ * Validation function, that checks If date form value is more than provided date
16250
+ */
16251
+ function minDateValidator(date, message = MessagesEnum$1.INVALID_DATE.replace('$1', new DatePipe('en-US').transform(date))) {
16252
+ return (control) => {
16253
+ if (!control.value) {
16254
+ return null;
16255
+ }
16256
+ // form control value can be as a Moment object - we wrap it in "new Date()" to work with it like with JS Date
16257
+ if (new Date(control.value) >= new Date(date)) {
16258
+ return null;
16259
+ }
16260
+ return { minDate: message };
16261
+ };
16262
+ }
16263
+
16264
+ /**
16265
+ * Validator that check if sum amount of provided fields is greater than provided sum
16266
+ * @param field to check in each formArray element
16267
+ * @param summary to compare with fields sum
16268
+ * @param fieldAlias to show it in error message
16269
+ */
16270
+ function fieldsSumValidator(field, summary = 100, fieldAlias) {
16271
+ return (formArray) => {
16272
+ // calculate sum of desired fields in formArray control
16273
+ const fieldsSum = formArray['controls']
16274
+ .reduce((acc, group) => acc += group.get(field).value, 0);
16275
+ if (fieldsSum <= summary) {
16276
+ return null;
16277
+ }
16278
+ else {
16279
+ return {
16280
+ fieldsSum: {
16281
+ name: field,
16282
+ alias: fieldAlias,
16283
+ summary
16284
+ }
16285
+ };
16286
+ }
16287
+ };
16288
+ }
16289
+
16290
+ /**
16291
+ * Validation function, that checks If provided date is within a current financial year
16292
+ */
16293
+ function currentFinYearValidator() {
16294
+ const currentFinYear = new FinancialYear();
16295
+ return (control) => {
16296
+ if (!control.value || control.value >= currentFinYear.startDate && control.value <= currentFinYear.endDate) {
16297
+ return null;
16298
+ }
16299
+ return { notCurrentFinYear: true };
16300
+ };
16301
+ }
16302
+
16303
+ const MAX_SIZE = 4194304;
16304
+ class FileValidator {
16305
+ // File max size check
16306
+ static fileMaxSize(maxSize = MAX_SIZE) {
16307
+ const validatorFn = (file) => {
16308
+ return file.size > maxSize ? { fileMaxSize: { maxSize } } : null;
16309
+ };
16310
+ return FileValidator.fileValidation(validatorFn);
16311
+ }
16312
+ // File extension check
16313
+ static fileExtensions(allowedExtensions = DOCUMENT_FILE_TYPES.all) {
16314
+ const validatorFn = (file) => {
16315
+ return allowedExtensions.includes(file.type) ? null : { fileExtension: { allowedExtensions: allowedExtensions.join() } };
16316
+ };
16317
+ return FileValidator.fileValidation(validatorFn);
16318
+ }
16319
+ static fileValidation(validatorFn) {
16320
+ return (formControl) => {
16321
+ if (!formControl.value) {
16322
+ return null;
16323
+ }
16324
+ return validatorFn(formControl.value);
16325
+ };
16326
+ }
16327
+ }
16328
+
16305
16329
  /**
16306
16330
  * Form array with bank account properties
16307
16331
  * @TODO create AbstractFormArray
@@ -16518,7 +16542,7 @@ class SoleContactForm extends AbstractForm {
16518
16542
  lastName: new UntypedFormControl(contact.lastName, Validators.required),
16519
16543
  email: new UntypedFormControl(contact.email, [Validators.required, Validators.email]),
16520
16544
  phone: new UntypedFormControl(contact.phone),
16521
- address: new AddressForm(contact.address || plainToClass(Address, {}))
16545
+ address: new UntypedFormControl(contact.address)
16522
16546
  }, contact);
16523
16547
  }
16524
16548
  }
@@ -17009,7 +17033,8 @@ function phoneNumberValidator() {
17009
17033
 
17010
17034
  class PhoneForm extends AbstractForm {
17011
17035
  constructor(
17012
- // no default value because this form is always built-in, so phone passed from parent form
17036
+ // no default value because Address form is always a child form. That's mean address value always passed and then default value never work.
17037
+ // even if null passed, default value will not work
17013
17038
  phone) {
17014
17039
  super({
17015
17040
  type: new UntypedFormControl((phone === null || phone === void 0 ? void 0 : phone.type) || PhoneTypeEnum.MOBILE, Validators.required),