Questions tagged [validation]

Validation is used to check data to make sure it fits whatever required specifications are set for it. Typically Validation is used in checking input data, and in verifying data before storage.

Data validation is the process of ensuring that a program operates on clean, correct and useful data. It applies rules or constraints to check for correctness, meaningfulness, and security of data that are input to the system.

The most common reasons for validation are to avoid entering data which violates a database schema, and to prevent unauthorized exploitation of a user interface.

Different kinds of validation

In evaluating the basics of data validation, generalizations can be made regarding the different types of validation, according to the scope, complexity, and purpose of the various validation operations to be carried out.

For example:

  1. Data type validation;
  2. Range and constraint validation;
  3. Code and Cross-reference validation; and
  4. Structured validation

Resources:

67160 questions
455
votes
9 answers

What's an appropriate HTTP status code to return by a REST API service for a validation failure?

I'm currently returning 401 Unauthorized whenever I encounter a validation failure in my Django/Piston based REST API application. Having had a look at the HTTP Status Code Registry I'm not convinced that this is an appropriate code for a validation…
michaeljoseph
  • 7,023
  • 5
  • 26
  • 27
451
votes
17 answers

How to set custom validation messages for HTML forms?

I've got the following HTML form: http://jsfiddle.net/nfgfP/

Remember…
Skizit
  • 43,506
  • 91
  • 209
  • 269
416
votes
40 answers

How to validate an e-mail address in swift?

Does anyone know how to validate an e-mail address in Swift? I found this code: - (BOOL) validEmail:(NSString*) emailString { if([emailString length]==0){ return NO; } NSString *regExPattern =…
giorgionocera
  • 6,428
  • 6
  • 20
  • 17
403
votes
35 answers

How can one use JQuery to validate email addresses?

How can one use JQuery to validate email addresses?
DuH
  • 4,047
  • 3
  • 16
  • 3
397
votes
18 answers

How to test valid UUID/GUID?

How to check if variable contains valid UUID/GUID identifier? I'm currently interested only in validating types 1 and 4, but it should not be a limitation to your answers.
Marek Sebera
  • 39,650
  • 37
  • 158
  • 244
361
votes
15 answers

JavaScript file upload size validation

Is there any way to check file size before uploading it using JavaScript?
ArK
  • 20,698
  • 67
  • 109
  • 136
359
votes
11 answers

How to check whether a string is a valid HTTP URL?

There are the Uri.IsWellFormedUriString and Uri.TryCreate methods, but they seem to return true for file paths, etc. How do I check whether a string is a valid (not necessarily active) HTTP URL for input validation purposes?
Louis Rhys
  • 34,517
  • 56
  • 153
  • 221
358
votes
8 answers

How do I remove javascript validation from my eclipse project?

I am using eclipse on my project and while messing around with my eclipse settings, I turned on Javascript support. Now eclipse complains that JQuery library has errors in it and is not letting me compile the project. Does anyone know how to turn…
Ritesh M Nayak
  • 8,001
  • 14
  • 49
  • 78
350
votes
24 answers

Number input type that takes only integers?

I'm using the jQuery Tools Validator which implements HTML5 validations through jQuery. It's been working great so far except for one thing. In the HTML5 specification, the input type "number" can have both integers and floating-point numbers. This…
JayPea
  • 9,551
  • 7
  • 44
  • 65
345
votes
21 answers

How to force an HTML form to validate without submitting it via jQuery

I have this form in my app and I will submit it via AJAX, but I want to use HTML for client-side validation. So I want to be able to force the form validation, perhaps via jQuery. I want to trigger the validation without submitting the form. Is it…
razenha
  • 7,660
  • 6
  • 37
  • 53
330
votes
9 answers

How can I manually set an Angular form field as invalid?

I am working on a login form and if the user enters invalid credentials we want to mark both the email and password fields as invalid and display a message that says the login failed. How do I go about setting these fields to be invalid from an…
efarley
  • 8,371
  • 12
  • 42
  • 65
287
votes
15 answers

What's the valid way to include an image with no src?

I have an image that I will dynamically populate with a src later with javascript but for ease I want the image tag to exist at pageload but just not display anything. I know is invalid so what's the best way to do this?
jhchen
  • 14,355
  • 14
  • 63
  • 91
287
votes
13 answers

How to validate an XML file against an XSD file?

I'm generating some xml files that needs to conform to an xsd file that was given to me. How should I verify they conform?
Jeff
  • 3,252
  • 3
  • 23
  • 13
281
votes
16 answers

How can I check if a single character appears in a string?

In Java is there a way to check the condition: "Does this single character appear at all in string x" without using a loop?
barfoon
  • 27,481
  • 26
  • 92
  • 138
274
votes
14 answers

XML Schema (XSD) validation tool?

At the office we are currently writing an application that will generate XML files against a schema that we were given. We have the schema in an .XSD file. Are there tool or libraries that we can use for automated testing to check that the…
Jason Dagit
  • 13,684
  • 8
  • 33
  • 56