1.0.0 • Published 6 years ago

ngx-mix-form v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

NgxMixForm

CustomValidators Build custom cross-field validators for Reactive Froms, ex where one field is required or not required based on state of another field

  • Build custom cross-field validators for Reactive Froms
  • Learn more on Medium
  • See a working example by clicking on CodePen

    class AppComponent implements OnInit  {
     registerForm: FormGroup;
     constructor( @Inject(FormBuilder) private formBuilder: FormBuilder) {}
    
     ngOnInit() {
          this.registerForm = this.formBuilder.group({
              firstName: ['', Validators.required],
              phone: ['', [Validators.pattern('[0-9]*')]],
              email: ['', [ Validators.email]]
          },
          {
            validator: [
              CustomValidators.requiredEither('email', 'phone')
            ]
          }
         );
      }

#NgxMixLibraries

Build, Deploy, Test and Try out

https://github.com/simars/ngx-mix-libraries/blob/master/README.md