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:

62584 questions
373
votes
35 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 =…
Giorgio Nocera
  • 5,798
  • 6
  • 17
  • 17
370
votes
14 answers

HTML5 form required attribute. Set custom validation message?

I've got the following HTML5 form: http://jsfiddle.net/nfgfP/
Skizit
  • 37,926
  • 89
  • 198
  • 265
361
votes
2 answers

Regex match one of two words

I have an input that can have only 2 values apple or banana. What regular expression can I use to ensure that either of the two words was submitted?
CyberJunkie
  • 18,604
  • 50
  • 135
  • 207
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
  • 7,801
  • 13
  • 47
  • 78
347
votes
20 answers

Check if a number has a decimal place/is a whole number

I am looking for an easy way in JavaScript to check if a number has a decimal place in it (in order to determine if it is an integer). For instance, 23 -> OK 5 -> OK 3.5 -> not OK 34.345 -> not OK if(number is integer) {...}
Hans
  • 9,917
  • 10
  • 45
  • 62
325
votes
12 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
  • 37,155
  • 34
  • 153
  • 231
306
votes
20 answers

How to force a html5 form validation without submitting it via jQuery

I have this form in my app and I will submit it via AJAX, but I want to use HTML5 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,240
  • 6
  • 34
  • 52
300
votes
14 answers

JavaScript file upload size validation

Is there any way to check file size before uploading it using JavaScript?
ArK
  • 18,824
  • 63
  • 101
  • 135
285
votes
22 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
  • 8,573
  • 7
  • 38
  • 62
281
votes
9 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
  • 30,777
  • 53
  • 137
  • 211
272
votes
13 answers

What's the best way 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. What's the best way to verify they conform?
Jeff
  • 3,102
  • 3
  • 20
  • 12
270
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,034
  • 8
  • 31
  • 54
251
votes
14 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
  • 13,225
  • 13
  • 57
  • 88
251
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
  • 6,781
  • 8
  • 36
  • 61
247
votes
19 answers

What is the best Java email address validation method?

What are the good email address validation libraries for Java? Are there any alternatives to commons validator?
jon077
  • 10,069
  • 11
  • 37
  • 35