richnologies / ngx-stripe

Angular 6+ wrapper for StripeJS
MIT License
219 stars 77 forks source link

Reactive Form Validation #24

Closed GeorgeKnap closed 6 years ago

GeorgeKnap commented 6 years ago

Hi Is it / Would it be possible to have an input binding to ngx-stripe-card component to pass in the FormGroup and the component would take care of form validation?

My point is I want to be able to use <button type="submit" [disabled]="stripeTest.invalid" ></button> on button to disable button if the fields in card component are not set or are invalid.

richnologies commented 6 years ago

HI @GeorgeKnap, I suppose we could, but I don't see the point.

I mean, in order for the component to take a formControl as a input, we should implement the ControlValueAccessor interface and then create some sort of Validator for the valid card.

I believe there are easier ways. Take a look at this example on stackblitz and let me know what you think.

https://stackblitz.com/edit/ngx-stripe-card-element-form?file=app%2Fapp.component.ts

If the code does not fulfill your needs, I am happy to further discuss this feature.

Thanks again to all of your for the suggestions and bug reports.

GeorgeKnap commented 6 years ago

@richnologies Thanks. The stackblitz example is great. That's all I neeed. I think you should put the code / link to readme.