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
13
votes
5 answers

asp.net CustomValidator never fires OnServerValidate

I have the following ASP page:
Add New…
Bryce Fischer
  • 5,026
  • 9
  • 27
  • 36
13
votes
6 answers

Validating double and float values using Hibernate Validator - bean validation

I'm looking for a way to validate a java.lang.Double field in the Spring command bean for its maximum and minimum values (a value must lie between a given range of values) like, public final class WeightBean { …
Tiny
  • 24,933
  • 92
  • 299
  • 571
13
votes
1 answer

Substitution arguments in ValidationAttribute.ErrorMessage

In an ASP.NET MVC 4 app, the LocalPasswordModel class (in Models\AccountModels.cs) looks like this: public class LocalPasswordModel { [Required] [DataType(DataType.Password)] [Display(Name = "Current password")] public string…
Bob.at.Indigo.Health
  • 9,166
  • 11
  • 51
  • 93
13
votes
4 answers

How to validate PasswordBox WPF

I'm trying to make a validation for a PasswordBox. For making validations I followed this link, that shows how to validate on TextBox. The problem comes with PasswordBoxes. Because its Password is not bindable due to security reasons, I tried to…
Sonhja
  • 7,513
  • 16
  • 64
  • 115
13
votes
5 answers

Empty values passed to Zend framework 2 validators

How can I pass an empty value through Zend framework 2 ValidatorChain to my custom validator? It was possible on ZF1 by allowEmpty(false) On ZF2 with empty element value : If allowEmpty = false, NotEmptyValidator is added to the top of…
deyine
  • 191
  • 1
  • 1
  • 14
13
votes
5 answers

How to cleanly verify if the user input is an integer in Ruby?

I have a piece of code where I ask the user to input a number as an answer to my question. I can do to_i but tricky/garbage inputs would escape through to_i. For example, if a user inputs 693iirum5 as an answer then #to_i would strip it to…
PriyankaK
  • 765
  • 2
  • 9
  • 16
13
votes
2 answers

on an ActiveModel Object, how do I check uniqueness?

In Bryan Helmkamp's excellent blog post called "7 Patterns to Refactor Fat ActiveRecord Models", he mentions using Form Objects to abstract away multi-layer forms and stop using accepts_nested_attributes_for. Edit: see below for a solution. I've…
JeanMertz
  • 2,210
  • 2
  • 21
  • 25
13
votes
4 answers

How can I validate a JSON string against a schema programmatically?

Are there simple libraries out there (.NET and Java) that are able to validate a JSON string given a schema definition? It should work similar to how XML can be validated using XSD. EDIT: I need .NET and Java libraries. Thanks to darin for the .NET…
user93202
13
votes
3 answers

How can Request Validation be disabled for HttpHandlers?

Is it possible to disable request validation for HttpHandlers? A bit of background - I've got an ASP.NET web application using an HttpHandler to receive the payment response from WorldPay. The IIS logs show that the handler is being called…
Mun
  • 13,678
  • 8
  • 54
  • 82
13
votes
9 answers

TimeZone validation in Java

I have a string, I need to check whether it is a standard time zone identifier or not. I am not sure which method I need to use. String timeZoneToCheck = "UTC"; I would like to check whether it represents a valid time zone or not.
user1772643
  • 535
  • 3
  • 9
  • 21
13
votes
1 answer

Rails/ActiveModel passing arguments to EachValidator

I have a very generic validator and I want to pass it arguments. Here is an example model: class User include Mongoid::Document field :order_type has_many :orders, inverse_of :user validates: orders, generic: true #i want to pass argument…
GTDev
  • 5,258
  • 8
  • 45
  • 80
13
votes
2 answers

Rails i18n specific error validation formats

So you can change an error message in en.yml with something like the following: en: activerecord: errors: models: foo: attributes: amount: greater_than_or_equal_to: "Custom GTOE error…
13
votes
3 answers

Should i sanitize markdown?

For my post entity i store both HTML and MARKDOWN in database (HTML is converted from MARKDOWN). HTML is for rendering on page and MARKDOWN for editing ability (with WMD). I sanitize HTML before storing to db. Question is: should i sanitize markdown…
admax
  • 1,563
  • 2
  • 15
  • 23
13
votes
4 answers

How to validate unique entities in an entity collection in symfony2

I have an entity with a OneToMany relation to another entity, when I persist the parent entity I want to ensure the children contain no duplicates. Here's the classes I have been using, the discounts collection should not contain two products with…
Jens
  • 5,066
  • 5
  • 46
  • 64
13
votes
3 answers

Non blank file input field in Symfony2 form

In my Doctrine entity, which is data_class for my form I have a file property defined like this: /** * Image. * * @Assert\NotBlank * @Assert\File * @Assert\Image(minWidth="138", minHeight="96") */ protected…
umpirsky
  • 9,358
  • 12
  • 65
  • 92
1 2 3
99
100