Tags for questions related to validating data.

learn more… | top users | synonyms

1
vote
0answers
58 views

What's the right way to approach validations? [closed]

I'm a rails developer, and have noticed that while defining validations I find myself confused about the scope I'm trying to cover. For example, I have basic cases where a field of data (ex: name, ...
2
votes
2answers
101 views

Why use a unique hashkey for form submissions?

I have multiple forms and use AJAX to submit them. I asked my boss if he needed any specific format for the form ID and he told me to generate a unique hash and keep it in session; check it whenever ...
0
votes
1answer
53 views

How to work with fail reason [duplicate]

Imagine that I have a method like User::validate($data), and mostly the developer expects only that is returns a boolean (true mean "ok, validated with success"). But, in some specific cases, he need ...
5
votes
2answers
104 views

Where should business logic go in a layered architecture?

First of all, i'm not talking about validation in the sense of the nullability or length of a field like in this and this questions where we can use isValid() methods in business classes or an ...
1
vote
0answers
37 views

Loading Aggregate Root from Database with Validations

Here is a similar question Where to validate domain model rules that depend on database content? I am asking this new question because I have more descriptions and I don't want to change the ...
4
votes
3answers
404 views

Java & REST API: How do I check for duplicate before inserting record?

I am developing an application in Java to parse and upload records from a CSV to an online database, via a REST API. While I know for sure that there are no duplicate records in each CSV file, I ...
1
vote
1answer
67 views

Rails validation: Which method is preferred

In Ruby on Rails there are two ways to validate, for instance, the presence of input fields. Say I want to make sure the user has filled out my fields called value and name. I could put in my model ...
2
votes
0answers
67 views

What's the best pattern to validate a conditional entity? [duplicate]

I'm developing an ASP.NET MVC 5 website and I have a view with a grid. In this grid I have a column which represents an URL property. This url is a link to download some files, but this url should be ...
2
votes
4answers
71 views

If I have a method that needs verification in order to proceed, do I call it inside the method or before? [duplicate]

This has been bothering me. This is more of a pragmatic problem than technical. Imagine I have a SaveOrderChanges method which, as its name implies, will save the order changes when the user submits ...
1
vote
1answer
67 views

File validation rules

I have an application that can accept CSV files to run some operations. The files look like: CREATE USER:username,last_name,first_name,age user1,Smith,John,23 user2,Poppins,Mary,257 There are a ...
1
vote
2answers
124 views

When writing a library or an API, when should and when shouldn't I validate or automatically correct errors in data provided by another developer?

I have a fairly good understanding of when data validation should and shouldn't exist when it comes when writing an application that is only dealt with by an end-user, and all the different tiers of ...
4
votes
3answers
99 views

How do I model this relationship so that it is valid by construction?

Imagine a device class that represents a physical real world mobile device, with fields like Enabled, Platform, Model IMEI, etc. Then, an operation class, which is something that needs to be done to a ...
29
votes
7answers
3k views

Should I validate a method call's return value even if I know that the method can't return bad input?

I'm wondering if I should defend against a method call's return value by validating that they meet my expectations even if I know that the method I'm calling will meet such expectations. GIVEN User ...
1
vote
2answers
219 views

Pattern for validating rules having different signatures

I have a class in charge of responding to an input event and maybe triggering another event. To decide, it has several rules to check. I'm trying to get away from a class looking like this: public ...
2
votes
1answer
68 views

Use of validators for simple validations

I've been working in Liferay code, and I've come across this construct a few times: List<?> list; ... if (Validator.isNotNull(list)) { //do stuff }} The source code for Validator.java ...
0
votes
1answer
122 views

Always set form input max length?

Background I'm looking to put together a single page web application with many form inputs. I've run into issues with other web pages where there is an ugly SQL error sent to the user if the ...
7
votes
2answers
517 views

What is best practice to handle whitespaces when letting the user edit the configuration, the name=value pairs?

For instance, you let the user define the notorious path variable. How do you interpret apppath = C:\Program Files\App? This looks like a programming language adopted practice to ignore the white ...
1
vote
0answers
78 views

How to consume inconsistent REST API with Mongo DB backend?

We are using a third party REST API and we are building one of the pages on our ASP.NET site around the data it delivers. We get results in JSON, and interact with it mostly using .NET MongoDB Driver. ...
1
vote
3answers
135 views

Coerce bad input or always crash early

The general consensus seems to favor the Crash Early approach, the most reputable source being the acclaimed Pragmatic Programmer book. And while I understand and agree with the advice in many ...
1
vote
2answers
340 views

Why all consider UAT a validation activity? It contradicts the original idea

Virtually any book dealing with software testing mentions that user acceptance testing (UAT) is an ultimate validation activity, often quoting Boehms informal definition: "Validation: Are building the ...
1
vote
4answers
487 views

Domain Model, validation, and pushing errors to the model

Looking into DDD and something I noticed is that business logic should be in the model, otherwise you just have property bags. That said how do you handle pieces of validation that require a trip to ...
5
votes
8answers
370 views

Do objects with validation logic in their domain really represent their real world counterparts?

I asked a question about whether validation behavior should be treated the same as other types of behavior in regard to the concept of OOP being "data + behavior". I got some good answers back that ...
3
votes
3answers
487 views

OOP: Behavior + Data, but what about 'validation' behaviors?

EDIT: Thanks for all the great answers! In reading these responses I realized that I'm approaching this from the wrong angle so I wrote a new question here. I had this discussion with my superior ...
3
votes
1answer
169 views

Difference between patterns: Specification, Guarding, Conditions, Monads, Validation,

I'm currently trying to get my head around a few patterns (especially the ones mentioned in the title above) that are made to address different problems and are being used in different parts of the ...
-1
votes
1answer
165 views

Is there a set of standards for data validation rules? [closed]

I'm trying to develop a generic data validation engine for web forms. Basically, the idea is to write a library that loads a JSON "validation schema", and then generates the appropriate server-side ...
3
votes
2answers
192 views

Should I throw guard exceptions that will be thrown by internal methods anyway? [duplicate]

I have some fairly simple code (C#): /// <summary> /// Truncates a string to a maximum length. /// </summary> /// <param name="value"> The string to truncate. ...
1
vote
2answers
184 views

Where should the “not empty field” validation code be written on a 3-layer application?

When working with the 3-layer model, where should the validation code be placed? for: not empty fields, unchecked options, null values, wrong-written dates, etc. To keep total isolation between a ...
1
vote
2answers
111 views

Writing a simple code validator

I know that programming languages can be defined in EBNF which can be converted into regular expressions. Right now I am working on a very simple BASIC interpreter for a project. The code has to be ...
3
votes
2answers
449 views

Where to put format validation in a CQRS “stylish” domain model?

It feels right to put format validation inside the domain objects (VOs or entities) because it is the natural place for high cohesion and the domain knows best what every domain ...
1
vote
2answers
79 views

Property value validations on POCO entities

Sorry in advance if this question is so trivial. The situation There is a Customer entity whose ID is limited to two letters (A to Z) in the database. Also, a user can enter the ID value from a ...
1
vote
1answer
602 views

Presenter accessing the value in text box using sender object

I have following method in my presenters which validates the user inputs on the UI. Basically to capture the value of the text property of the text box, it uses sender object which was passed in by ...
3
votes
4answers
117 views

Can I save & store a user's submission in a way that proves that the data has not been altered, and that the timestamp is accurate?

There are many situations where the validity of the timestamp attached to a certain post (submission of information) might be invaluable for the post owner's legal usage. I'm not looking for a service ...
5
votes
4answers
1k views

Managing client-side and server-side validations in one place

I'm 100% on board with the case that one should definitely use both client-side and server-side data validations. However, in the frameworks and environments I've worked in, the approaches I've seen ...
2
votes
2answers
201 views

Allowing enum to express a valid combination of values

Suppose in a manufacturing environment, there are certain stock materials available for use in a product. For example, there are only a few different sizes of copper tube, each having a specific ...
1
vote
2answers
179 views

Is input validation necessary?

This is a very naive question about input validation in general. I'm a MATLAB user (1.5 years old) and I learned about input validation techniques such as "parse" and "validatestring". In fact, ...
0
votes
1answer
210 views

DataSet Validation vs. ASP.NET MVC Validation

I have a general question on where to put validation. I have an asp.net mvc that gets/sets data from/to a DataSet. Currently, the fields in the form are validated by the form itself (e.g. for ...
4
votes
4answers
4k views

Best way of validating Class properties

Background: I have a CSV file, which I need to ready and validate each element in each row and create a collection of a class, having valid data. i.e CSV File looks like: ...
0
votes
1answer
66 views

How to prevent re-checking already-checked data?

I have a class with a validId($id) method that is called by the constructor and by public function load($id). The method queries the database to see if the id exists and returns true/false. The ...
1
vote
3answers
803 views

How can I write complex validation and business logic that can be reused in both direct data model changes and pending dialog changes?

I was hoping for some advice: I need to design a software solution for a medium-sized java / Swing application. The application will have about 200 use cases requiring complex data validation and ...
1
vote
2answers
188 views

Setter Validation can affect performance?

In a scenario where you use an ORM to map your entities to the DB and you have setter validations (nullable, date lower than today validation, etc), every time the ORM gets a result, it will pass into ...
3
votes
2answers
1k views

Validation and data persistence in a domain model

My (first and current) workplace (a .NET shop) suffers from an over-abundance of anemic domain models, to the extent that I don't really know how validation and data persistence should be handled in a ...
7
votes
2answers
1k views

Where to validate domain model rules that depend on database content?

I'm working on a system that allows Administrators to define Forms that contain Fields. The defined Forms are then used to enter data to the system. Sometimes the Forms are filled by a human via a ...
0
votes
4answers
165 views

Should user input of a contact form be validated?

On software company websites I visit the first time, I often open the "Contact us" page and try to submit the contact form with all fields empty. I am just curios if they validate the user input. If ...
7
votes
1answer
2k views

Duck typing, data validation and assertive programming in Python

About duck typing: Duck typing is aided by habitually not testing for the type of arguments in method and function bodies, relying on documentation, clear code and testing to ensure correct use. ...
6
votes
6answers
1k views

If the model is validating the data, shouldn't it throw exceptions on bad input?

Reading this SO question it seems that throwing exceptions for validating user input is frowned upon. But who should validate this data? In my applications, all validations are done in the business ...
12
votes
5answers
894 views

Strengthening code with possibly useless exception handling

Is it a good practice to implement useless exception handling, just in case another part of the code is not coded correctly? Basic example A simple one, so I don't loose everybody :). Let's say I'm ...
4
votes
8answers
1k views

Best Practice for Argument Checking

Say I have a web service with a method MyWebServiceMethod(string passedValue). The web service calls a method MyServiceMethod(string passedValue) where the value from the web service is passed along. ...
3
votes
3answers
239 views

Complex Mutual Exclusion Validation Logic

I need to validate some form inputs in complex way. E.g. <select id="options" multiple="multiple"> <option>A</option> <option>B</option> ...
2
votes
3answers
313 views

Approach to use for user email address change in application?

As the title says, if the user wants change their email address in the application, in terms of programming, what approach (process) to use? Where do you store the new email address until the user ...
3
votes
5answers
1k views

Why validate XML?

I am looking for an explanation on just why XML needs to be validated. I have been testing DTD's and Schema's for the past month and recently tried to find out why I am doing this. I know it makes the ...