siva636
siva636

Reputation: 16441

Temporarily disabling form validation in AngularJS

I have done client side form validation using AngularJS, it works like a charm!

Then, I implemented server side validation and I want to test it by sending wrong data to the server. AngularJS (client side form validation) does not allow me to send wrong data to the server!

What can I do?

(Disabling Javascript cannot be a choice, because it will stop all ajax calls and thus no server side methods are called in my application)

Summery of the question:

users compromise front end validation (yes, it happens in practice!), how can I do the same for testing?

Upvotes: 1

Views: 721

Answers (1)

Michael Benford
Michael Benford

Reputation: 14104

What you're asking doesn't make much sense. Angular does not prevent a request from being sent for any reason. If your form does that, it's only because you have coded it to do so. So, disabling validation in your case would be just a matter of commenting out the code that enforces it (that doesn't remain true if you're using custom validators. In that case, it may be a lot harder to disable validation altogether).

But, I wouldn't do that. In order to test your server-side validation, I suggest that you do one of the following:

  1. Write automated tests in the language your back-end was implemented and let them ensure your validation logic works (highly recommended);
  2. Manually do the tests by calling your back-end API directly. You could use Fiddler if you happen to be using Windows, or Postman for Google Chrome on any operating system.

Upvotes: 2

Related Questions