Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [validation]

Tags for questions related to validating data.

3
votes
2answers
103 views

Why is it bad to use exceptions for handling this type of validation? It seems like it makes the code so much cleaner

I'm working on a .NET Core REST API and I'm writing a service class to create new user accounts. I have the following code: public async Task<UserDto> RegisterNewUserAccount(...
1
vote
2answers
55 views

Where should tests and checks be implemented in a mathematical modelling process?

I have a mathematical model with two main "stages" 1. data loading (only a few KB of data) and 2. running a model on the data. I want to implement some tests and checks to ensure the data being fed ...
-1
votes
4answers
284 views

In a Domain Driven Development DDD, have a validation on a DTO that calls a external service is wrong, if yes, where should it be?

I have this question, is more about pattern and in theory what is wrong or not instead of if is possible or not (because it is). In a DDD design, I have a DTO that I am validating, to check not nulls,...
1
vote
2answers
238 views

DDD - How to do informative validation (specifically on entity creation)?

For my domain entities currently, all validation errors cause exceptions to be thrown. I don't like this as it doesn't allow me to compile all validation errors before exiting a method. I'd like to ...
-2
votes
1answer
42 views

Should we delegate user input sanitization/validation?

Consider this code: new FrameworkClass( [ 'query' => $_POST[ 'input' ] ] ); FrameworkClass is supposed to do input sanitization and validation. Should we just trust 3rd party code to do it's job? ...
1
vote
1answer
46 views

Using the objects retrieved at the time of request validation

I hope the question title already answers the subject here. Lets say I have a number of ids that needs to be validated in a request. Example: request uri: [POST] /album/{album_id}/song Request ...
3
votes
3answers
168 views

What to do when an aggregate is given a bad event?

What is usually done when an aggregate is asked to apply an "impossible" event to its state? For example, if a ShoppingCart aggregate has already applied a CustomerAckRec (The customer has ...
0
votes
3answers
210 views

Formatting a string by converting to a number then back to a string

I'm not sure whether this qualifies as code smell, or if there may be some better way of performing the same task, but, basically, I want to format a 10 digit string, using C#, and have the following ...
0
votes
0answers
141 views

Fluent validation - integrate in my business objects best practices

I am involved in the development of a price engine system. I have a set of business objects like Car, Engine, Wheels, etc I want to validate them using the framework Fluent Validation Here an example:...
2
votes
2answers
214 views

Should I fix known bad domains in user emails?

Checking my Sendgrid account I've noticed many drops due to "Known bad domain". Those bad domains often seem to have been caused due to user mistake. ***@gmal.com ***@gmail.com.br ***@hotmal.com I ...
0
votes
3answers
77 views

Prefixing a number with + on html inputs

When asking for positive number inputs on html, is it valid to allow + on the textbox? Like +42? Surely the + sign gets removed during server-side processing. But will allowing + be fine on the html ...
66
votes
7answers
15k views

If functions have to do null checks before doing the intended behaviour is this bad design?

So I don't know if this is good or bad code design so I thought I better ask. I frequently create methods that do data processing involving classes and I often do a lot of checks in the methods to ...
0
votes
3answers
176 views

How far do you go in server-side validation of POST/GET requests?

Our application had a few vulnerabilities detected by AppScan and we had to add server-side validation to catch SQL injection attempts. But my question is, how far do you go in server-side ...
2
votes
1answer
45 views

Should the ORM create the related objects (ForeignKey objects) when saving the entity?

This question is coming from a frustration when using the Entity Framework and ASP.NET MVC, but I assume it's a general frustration across more frameworks and languages. Lets say we have an object ...
23
votes
6answers
4k views

Is it ok to have validation layer before access control layer

I am creating an API strcutured web application and in this application we have different layers which are doing their own job. First layer is Validation layer which validate user input and if it ...
0
votes
1answer
198 views

JS Captcha in contact form validation to avoid spam bots

I am looking for opinions about how bulletproof could be this captcha system to avoid spam in a contact form. The form submit goes through ajax. So I generate 2 random numbers with javascript. The ...
-2
votes
3answers
83 views

How to handle submitted data - sanitization or validation or both?

As I was working on upgrading deprecated ereg_replace() statements in an e-cart sollution I was suddenly puzzled by questions regarding how to handle the submitted data I was working with. I was ...
1
vote
3answers
519 views

Validate JSON on server side

I'm working on Web Application (ASP.Net MVC) that will allow users to edit a JSON object in the browser and save it to database. To do so, JSON object will be sent from view to server side (...
2
votes
2answers
111 views

Designing for the validation of phone numbers

Let's say we have a registration system that finalises the creation of an account by SMSing the user their new account details. This system could be used by people all around the world, so let's say ...
6
votes
5answers
316 views

Message validation in async messaging-based services

I'm looking for information on the best approach to message validation in asynchronous-messaging-based services (i.e. services that pull messages from some sort of message queue or broker, rather than ...
1
vote
0answers
539 views

design pattern/oop for large validation rule set

I'm writing this in node.js I have some data that needs validating before anything can be done with this. The data is validated in two different ways. I can use JSONSchema to validate the structure ...
2
votes
1answer
79 views

Validation layer of clustered WebApi solution

Currently I have a design problem, which I am not sure how exactly to solve and what would be the best approach. So what I have is a ASP.NET Core WebApi project which is actually clustered solution. ...
2
votes
4answers
325 views

JavaScript only validation on AJAX form submit

I've been mulling this question over for a few days in my head and I can't come to a solid answer. We understand that client side validation for forms is not enough, because you can easily turn ...
0
votes
2answers
131 views

How to validate reference use?

I use "reference" term here like in C++ world, not like in C# (for example). I use non-C++ syntax on purpose -- this is general question, not about this particular implementation. Starting something ...
2
votes
3answers
105 views

The “scope” of knowledge about what the valid parameters are

I have a question which I'm not sure how to generalize and ask properly, so I'll try with an example. Suppose that I design a parking lot management system. In my system, I have the objects Car and ...
3
votes
4answers
607 views

Should I assert the preconditions of functions in a public API?

I am writing a library for some data structures in C that will be used in embedded systems. I have had issues designing and coming up with a solid error handling plan. This API is only subject to ...
0
votes
2answers
2k views

Overall view validation with a datagrid and keeping to MVVM

I am struggling to find a good architecture for what must be a common problem Enable/Disable a button in a View that contains a datagrid, and has validation requirements on the cell, row and ...
4
votes
2answers
925 views

Multi-level validation in C#

I have a Console project reads inputs from CSV file and tries to save them to database. For that, I created a class Person that maps a CSV row. The CSV file has two columns Name and Age. Person ...
0
votes
1answer
198 views

Validation Rule or Business Rule

I am in a confusion where I cannot decide whether a rule is validation rule or Business rule. I have simple POJO with JSR 303 bean validation rules. public class VehicleDto { @NotNull(message = "...
1
vote
1answer
276 views

Best approach for name similarity

As part of validation, we perform name similarity check and allow only if the threshold is reached. I got some help from StackOverflow regarding the implementation and finally implemented JaroWinkler ...
0
votes
2answers
157 views

Where should I enforce that an entity has between 0 and 7 attributes

Background I need to implement a URL whitelist to limit the number of pages that a javascript widget can be deployed on. The requesting domain is already limited for an account, but I now want to ...
2
votes
2answers
242 views

Would an age between 0 and 17 cause validation to fail? [closed]

I recently asked a question about validation here: What is the "best" way to apprach validation from the perspective of a DDD purist? Please see the code below, which I borrowed from here: ...
0
votes
2answers
74 views

Validating requests to API have come from a valid source

I am currently working on a project where I am developing a library which will do HTTP POSTs to a backend service on my server. The data that the backend service receives is processed and stored in a ...
1
vote
2answers
74 views

Should an empty validation pass if no rules supplied? [closed]

If I have a validator class with a validate function that takes a ruleContainer as input. Should the validation pass if the container is empty ( least astonishment?) or should I throw an exception or ...
3
votes
4answers
883 views

With a REST API, is there a convention for clients validate a request without committing any changes?

This may be easiest to explain with an example use case. Let's say I have an e-commerce site where users can add items to their shopping cart. When adding items to the cart, users can type in the ...
0
votes
1answer
1k views

How to represent and validate website URLs for a JPA entity

I have an application that will allow the user to enter and store (in a DB) a website URL for a company. The only requirement (as of now) beyond entry of the website URL is to validate that the URL is ...
2
votes
3answers
201 views

Validating Arguments in Constuctor

In general, I like to favour immutability where possible and not allow objects to be created in an invalid state or get into an invalid state. Sometimes though it feels like it might go too far. ...
0
votes
2answers
104 views

Design Gaps Validation

Does anybody face the issue with Design Validation and related overheads? When we deliver a Solution we have a lot of so-called Streams (usually 3-8, average 5). Each Stream is responsible for its ...
8
votes
4answers
3k views

Clean architecture validation in domain vs data persistence layer?

I'm studying up on clean and as a result am quite dramatically rethinking a great deal of how I design and write software. I've thing I'm still wrestling with however, is for business rules like "on ...
3
votes
4answers
2k views

How to avoid double data validation in an application with web interface?

I am learning software design by building a CRUD web application (ASP.NET MVC with Entity Framework). I split it into two projects: first is Core library, that contains business logic, second is Web ...
0
votes
0answers
109 views

Declarative model for data validation with interdependent values

I'm working on a system, which requires input validation with constraints between different input values. Besides input validation, there should also be inference depending on other configured values. ...
3
votes
3answers
198 views

Are periodic validation or verification tests required after the software is released?

I'm working as a programmer in a load cell manufacturing company. We develop our own software for load cell manufacturing and testing purposes. Quality Assurance Department of our company has ...
2
votes
2answers
1k views

Should a backend Restful API implement data validation

I am working a project which involves back-end Restful API and single-page front-end app. I am wondering if the back-end API has to implement all sort of data validation logic , which is also to be ...
1
vote
0answers
121 views

MVC remote validation approach

I have a model, the model has 2 strings; foo and bar. foo is what it is, it will be one of x amount of possible values (it's not an enum, though). bar is entered by the user, so I want to validate ...
10
votes
3answers
403 views

How to perform input validation without exceptions or redundancy

When I'm trying to create an interface for a specific program I'm generally trying to avoid throwing exceptions that depend on non-validated input. So what often happens is that I've thought of a ...
-1
votes
1answer
93 views

method to check nested transaction

So I am writing a method to check and throw if a new transaction is being made in another transaction. I first came up with straight forward checkNestedTransaction, but this seems vague since I cannot ...
1
vote
0answers
36 views

Database Constraint from another table column

Let's consider the following objects : Article which can be of different types Equipment which point to an Article, some fields on equipment are only used for some types. I want to add constraint ...
0
votes
1answer
44 views

Validating an app's feature

I am currently coding a productive study app. In my app, the user can input a list of productive, non-productive and necessary tasks which he will be doing throughout a period of time. The user is ...
1
vote
0answers
143 views

Putting NoSQL DB schemas on front-end, safely

We are using Firebase which is probably similar to MongoDB in that it stores arbitrary JSON structures. We are also using Node.js and so the library in question could in theory be used both backend ...
4
votes
4answers
719 views

How should I report multiple errors as a result of validation?

Say, I have a function, RegisterUser() which takes in an user's registration details such as their username, name and password and registers them if there is no invalid data. For such functions, it is ...