Skip to content

Commit 2541558

Browse files
committed
Rename errorStateFn to errorStateMatcher
1 parent 2141c4e commit 2541558

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

src/demo-app/input/input-demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ <h4>Inside a form</h4>
9696
</form>
9797

9898
<h4>With a custom error function</h4>
99-
<md-input-container [errorStateFn]="customErrorStateFn">
99+
<md-input-container [errorStateMatcher]="customErrorStateMatcher">
100100
<input mdInput placeholder="example" [(ngModel)]="errorMessageExample4" required>
101101
<md-error>This field is required</md-error>
102102
</md-input-container>

src/demo-app/input/input-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class InputDemo {
4242
}
4343
}
4444

45-
customErrorStateFn(c: NgControl): boolean {
45+
customErrorStateMatcher(c: NgControl): boolean {
4646
const isDirty = c.dirty;
4747
const isInvalid = c.invalid;
4848

src/lib/input/input-container.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('MdInputContainer', function () {
5757
MdInputContainerWithDynamicPlaceholder,
5858
MdInputContainerWithFormControl,
5959
MdInputContainerWithFormErrorMessages,
60-
MdInputContainerWithCustomErrorStateFunction,
60+
MdInputContainerWithCustomErrorStateMatcher,
6161
MdInputContainerWithFormGroupErrorMessages,
6262
MdInputContainerWithId,
6363
MdInputContainerWithPrefixAndSuffix,
@@ -671,11 +671,11 @@ describe('MdInputContainer', function () {
671671
});
672672
}));
673673

674-
it('should display an error message when a custom error function returns true', async(() => {
674+
it('should display an error message when a custom error matcher returns true', async(() => {
675675
fixture.destroy();
676676

677-
let customFixture = TestBed.createComponent(MdInputContainerWithCustomErrorStateFunction);
678-
let component: MdInputContainerWithCustomErrorStateFunction;
677+
let customFixture = TestBed.createComponent(MdInputContainerWithCustomErrorStateMatcher);
678+
let component: MdInputContainerWithCustomErrorStateMatcher;
679679

680680
customFixture.detectChanges();
681681
component = customFixture.componentInstance;
@@ -1017,20 +1017,20 @@ class MdInputContainerWithFormErrorMessages {
10171017
@Component({
10181018
template: `
10191019
<form #form="ngForm" novalidate>
1020-
<md-input-container [errorStateFn]="customErrorStateFn.bind(this)">
1020+
<md-input-container [errorStateMatcher]="customErrorStateMatcher.bind(this)">
10211021
<input mdInput [formControl]="formControl">
10221022
<md-hint>Please type something</md-hint>
10231023
<md-error>This field is required</md-error>
10241024
</md-input-container>
10251025
</form>
10261026
`
10271027
})
1028-
class MdInputContainerWithCustomErrorStateFunction {
1028+
class MdInputContainerWithCustomErrorStateMatcher {
10291029
@ViewChild('form') form: NgForm;
10301030
formControl = new FormControl('', Validators.required);
10311031
errorState = false;
10321032

1033-
customErrorStateFn(c: NgControl): boolean {
1033+
customErrorStateMatcher(c: NgControl): boolean {
10341034
return this.errorState;
10351035
}
10361036
}

src/lib/input/input-container.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ export class MdInputContainer implements AfterViewInit, AfterContentInit, AfterC
338338
private _floatPlaceholder: FloatPlaceholderType = 'auto';
339339

340340
/** A function used to control when error messages are shown. */
341-
@Input() errorStateFn: (control: NgControl) => boolean;
341+
@Input() errorStateMatcher: (control: NgControl) => boolean;
342342

343343
/** Reference to the input's underline element. */
344344
@ViewChild('underline') underlineRef: ElementRef;
@@ -396,7 +396,7 @@ export class MdInputContainer implements AfterViewInit, AfterContentInit, AfterC
396396
/** Whether the input container is in an error state. */
397397
_isErrorState(): boolean {
398398
const control = this._mdInputChild._ngControl;
399-
return this.errorStateFn ? this.errorStateFn(control) : this._defaultErrorStateFn(control);
399+
return this.errorStateMatcher ? this.errorStateMatcher(control) : this._defaultErrorStateMatcher(control);
400400
}
401401

402402
/** Determines whether to display hints or errors. */
@@ -405,7 +405,7 @@ export class MdInputContainer implements AfterViewInit, AfterContentInit, AfterC
405405
}
406406

407407
/** Default error state calculation */
408-
private _defaultErrorStateFn(control: NgControl): boolean {
408+
private _defaultErrorStateMatcher(control: NgControl): boolean {
409409
const isInvalid = control && control.invalid;
410410
const isTouched = control && control.touched;
411411
const isSubmitted = (this._parentFormGroup && this._parentFormGroup.submitted) ||

0 commit comments

Comments
 (0)