### File

`projects/app-base-library/src/lib/angular/directives/validators/email-validator.directive.ts`

### Metadata

providers | `{ : , : (() => ), : true }`
selector | `[validateEmail][ngModel],[validateEmail][formControlName],[validateEmail][formControl]`

### Index

###### Properties

- validator

###### Methods

- validate

### Constructor

`constructor()`
Defined in projects/app-base-library/src/lib/angular/directives/validators/email-validator.directive.ts:25

### Methods

validate
`validate(c: FormControl)`
Defined in projects/app-base-library/src/lib/angular/directives/validators/email-validator.directive.ts:31

Parameters :

Name | Type | Optional
c | `FormControl` | no

Returns : `any`

### Properties

validator
`validator: `Function``
Type : `Function`
Defined in projects/app-base-library/src/lib/angular/directives/validators/email-validator.directive.ts:25

    import { Directive, forwardRef } from '@angular/core';
    import { NG_VALIDATORS, FormControl } from '@angular/forms';
    import { validationConstants } from '../../../shared/index';

    function validateEmailFactory() {
        return (c: FormControl) => {
            const EMAIL_REGEXP = validationConstants.REGEX_EMAIL;
            return EMAIL_REGEXP.test(c.value) ? null : {
                validateEmail: {
                    valid: false
                }
            };
        };
    }

    @Directive({
        selector: '[validateEmail][ngModel],[validateEmail][formControlName],[validateEmail][formControl]',
        providers: [
            { provide: NG_VALIDATORS, useExisting: forwardRef(() => EmailValidatorDirective), multi: true }
            // { provide: NG_VALIDATORS, useExisting: forwardRef(() => EmailValidatorDirective), multi: true }
        ]
    })
    export class EmailValidatorDirective {

        validator: Function;

        constructor() {
            this.validator = validateEmailFactory();
        }

        validate(c: FormControl) {
            return this.validator(c);
        }
    }

# results matching ""

# No results matching ""