bia-framework
Version:
Bia Framework to work with angular 2
39 lines (34 loc) • 1.37 kB
text/typescript
import {Directive, Host, Attribute, OnInit, Optional} from "@angular/core";
import {Validators} from "@angular/forms";
import {CoreFormControlBase} from "../CoreFormControlBase";
import {CoreFormInput} from "../core-form-input/core-form-input.component";
import {CoreFormDropDown} from "../core-form-dropdown/core-form-dropdown";
// const provideParent =
// ( component:any, parentType?:any ) =>
// {
// return {provide: parentType || CoreFormInput, useExisting: forwardRef(() => component)};
// };
(
{
selector: 'validation-required'
}
)
export class CoreFormValidationRequired implements OnInit
{
private host:CoreFormControlBase;
ngOnInit():any
{
if (this.host != null)
this.host.addFormValidator({
ValidationName: 'required',
ValidationMessage: this.validationRequiredMessage
}, Validators.required);
return undefined;
}
constructor( () () private inputHost:CoreFormInput,
() () private dropDownHost:CoreFormDropDown,
("message") private validationRequiredMessage:string )
{
this.host = inputHost || dropDownHost;
}
}