ngx-render-material-forms 1.3.5 → 1.3.6

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.
@@ -513,10 +513,12 @@ class MaterialTextfieldComponent extends MaterialComponent {
513
513
  this.controlHasError = this.control.hasError(msg.context.validator);
514
514
  }
515
515
  if (msg.context && this.controlHasError) {
516
- if (this.instance.parent.submission.data.submit) {
517
- this.control.markAllAsTouched();
516
+ if (this.instance && this.instance.parent && this.instance.parent.submission && this.instance.parent.submission.data) {
517
+ if (this.instance.parent.submission.data.submit) {
518
+ this.control.markAllAsTouched();
519
+ }
518
520
  }
519
- return this.instance.error.message;
521
+ return this.instance.error ? this.instance.error.message : '';
520
522
  }
521
523
  }
522
524
  }
@@ -1060,10 +1062,14 @@ class MaterialTextareaComponent extends MaterialComponent {
1060
1062
  this.instance.attachElement(this.textarea.nativeElement);
1061
1063
  }
1062
1064
  getErrorMessage() {
1063
- if (this.instance.parent.submission.data.submit) {
1064
- this.control.markAllAsTouched();
1065
+ // Check if instance and necessary properties exist
1066
+ if (this.instance && this.instance.parent && this.instance.parent.submission && this.instance.parent.submission.data) {
1067
+ if (this.instance.parent.submission.data.submit) {
1068
+ this.control.markAllAsTouched();
1069
+ }
1065
1070
  }
1066
- return this.instance.error.message;
1071
+ // Return the error message if it exists
1072
+ return this.instance.error ? this.instance.error.message : '';
1067
1073
  }
1068
1074
  getValue() {
1069
1075
  return isNil(this.control.value) ? '' : this.control.value;