How to use the ngx-validators.CreditCardValidators.isCreditCard function in ngx-validators

To help you get started, we’ve selected a few ngx-validators examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Nightapes / ngx-validators / examples / src / app / reactive-forms / creditcard-validator / creditcard-validator.component.ts View on Github external
import { CreditCardValidators } from 'ngx-validators';
import { FormGroup, FormControl, Validators, FormBuilder } from '@angular/forms';
import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-reactive-creditcard-validator',
  templateUrl: './creditcard-validator.component.html',
  styleUrls: ['./creditcard-validator.component.css']
})
export class ReactiveFormCreditcardValidatorComponent implements OnInit {

  form: FormGroup;
  creditcard = new FormControl('', Validators.compose([CreditCardValidators.isCreditCard]));
  constructor(protected _fb: FormBuilder) { }

  ngOnInit() {
    this.form = this._fb.group({
      'creditcard': this.creditcard,
    });
  }

}