Skip to content

Commit

Permalink
feat(md-input): add md-validate-success attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Ullfis committed Aug 27, 2016
1 parent 56bea20 commit 1bb0a8e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions sample/src/samples/input/aurelia-validation.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<md-input
md-label="Last Name"
md-placeholder="Last Name"
md-validate-success="good"
md-value.bind="lastName & validate:rules">
</md-input>
</div>
Expand Down
8 changes: 4 additions & 4 deletions sample/src/samples/input/aurelia-validation.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { inject } from 'aurelia-framework';
import { inject, NewInstance } from 'aurelia-framework';
import { ValidationController, validateTrigger } from 'aurelia-validation';
import { ValidationRules } from 'aurelia-validatejs';

@inject(ValidationController)
@inject(NewInstance.of(ValidationController))
export class AureliaValidation {
firstName = '';
lastName = 'Doe';
myErrors = [];

rules = ValidationRules
.ensure('firstName').required()
.ensure('lastName').required();
.ensure('lastName').length({ minimum: 4 }).required();

constructor(controller: ValidationController) {
this.controller = controller;
this.controller.validateTrigger = validateTrigger.manual;
this.controller.validateTrigger = validateTrigger.change;
}

validateModel() {
Expand Down
4 changes: 4 additions & 0 deletions src/input/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class MdInput {
defaultBindingMode: bindingMode.oneTime
}) mdValidate = false;
@bindable() mdValidateError;
@bindable() mdValidateSuccess;
@bindable({
defaultBindingMode: bindingMode.twoWay
}) mdValue = '';
Expand All @@ -52,6 +53,9 @@ export class MdInput {
if (this.mdValidateError) {
this.label.setAttribute('data-error', this.mdValidateError);
}
if (this.mdValidateSuccess) {
this.label.setAttribute('data-success', this.mdValidateSuccess);
}
if (this.mdPlaceholder) {
this.input.setAttribute('placeholder', this.mdPlaceholder);
}
Expand Down

0 comments on commit 1bb0a8e

Please sign in to comment.