Skip to content

Commit

Permalink
bug fix: "I want to decide it is own when and what I will to validate!"
Browse files Browse the repository at this point in the history
  • Loading branch information
optimistex committed Dec 15, 2017
1 parent 516ce63 commit b799bf0
Show file tree
Hide file tree
Showing 2 changed files with 298 additions and 231 deletions.
6 changes: 4 additions & 2 deletions src/select/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ let styles = `
{
provide: NG_VALIDATORS,
useExisting: forwardRef(() => SelectComponent),
multi: true,
multi: true
}
],
template: `
Expand Down Expand Up @@ -529,12 +529,14 @@ export class SelectComponent implements OnInit, ControlValueAccessor, AfterConte
}

public validate(c: FormControl): any {
console.log('SelectComponent.validate');

let controlValue = c ? c.value : [];
if (!controlValue) {
controlValue = [];
}

return (controlValue.length > 0) ? null : {
return this.allowClear || (controlValue.length > 0) ? null : {
ng2SelectEmptyError: {
valid: false
}
Expand Down
Loading

0 comments on commit b799bf0

Please sign in to comment.