Questions tagged [validation]
Tags for questions related to validating data.
282 questions
1
vote
2
answers
180
views
Proper place to validate JSON in an ASP.NET core app
I am building an ASP.NET Core 10.0 web-app using .NET's MVC model w/ Kestrel to serve it. The app will deploy on an Azure VM. It's a personal project, therefore, I decided to go with Cosmos DB as the ...
5
votes
3
answers
433
views
When is multiple validation layers of protection necessary?
I'm having a hard time of understanding at what point is multiple layers of validation protection necessary rather than a single point of failure and if the performance hit is a concern
Lets say you ...
13
votes
13
answers
3k
views
Should setters silently sanitize input — or should they just throw? [closed]
Suppose the code's inside some FullName class
And suppose I want only capitalized name elements (let's ignore the fact that in some cultures, name elements may start with a lower-case letter)
Should I ...
1
vote
4
answers
545
views
Combining multiple input validations into one exception
In order to make sure methods fail fast under invalid arguments, I usually do validation at the start of a method. If I'm verifying multiple predicates, this leads to a few lines of checkNotNull or ...
1
vote
3
answers
347
views
Where to handle Validation Errors in Business logic layer?
I'm currently designing a multi-layered application and am trying to figure out the best practice for error handling within the Business Logic Layer (BLL).
Should I handle errors directly within the ...
0
votes
3
answers
180
views
Design a test framework for validating static files
I have a task to develop a test framework - or a test suite, if it makes more sense - that aims to validate properties over a large set of XML files.
Our codebase is basically like this:
JSON input ...
3
votes
4
answers
2k
views
Is validation part of presentation layer or business logic? [duplicate]
We're working on a new project (backend, API), following the "clean code" and "clean architecture" principles (described in Robert Martin's books), dividing our application into ...
0
votes
1
answer
157
views
API design question: Should a builder perform expensive validation when building?
I'm working on a library of C++ wrappers/bindings, for another, C-ish, API.
The C'ish API has a "launch" function, which, among other things, takes a launch configuration structure (well, ...
1
vote
2
answers
280
views
Request validation on API proxy
I am creating an API proxy that acts as a bridge between our frontend application and an AWS opensearch server. This proxy has additional features such as retries and timeouts.
One of the features I'm ...
0
votes
1
answer
95
views
Validating data and logic outside the domain
I have a budget entity in my domain which can be closed by the user if the budget is open. This means if the budget opens today and closes in seven days, in between this time I can close it, not ...
10
votes
6
answers
6k
views
How to ensure data consistency in system with multiple databases?
Let's say, in a rather big application suite with multiple more or less integrated products, data is stored across multiple databases. Some of them are SQL-ish DB clusters, some are MongoDB clusters.
...
2
votes
1
answer
672
views
Centralize input validation across multiple Microservices
My company, which specializes in logistics and transportation, delegated the majority of the backend microservices to our team. All of the microservices (which our team inherited from "past ...
0
votes
0
answers
70
views
How to group together common allowed descendants of a vertex in a tree data data structure?
I created an abstract class to represent a vertex in a tree structure. Later, a requirement was introduced where certain types of vertices are not allowed as descendants of certain other vertices. So ...
2
votes
1
answer
655
views
Reduce Code Repetition for a Simple CQRS
We're currently exploring CQRS in our future applications. To give a bit of a background, we use a simple CRUD-style service before something like this.
Old Pattern:
Controller
Command/Service
Model
...
1
vote
1
answer
242
views
Wrapper class for min/max clamping and validation
I have a lot of classes that have numeric values that are configurable by the customer during runtime and should be clamped between a min and a maximum value. The value changes should also be logged. ...
0
votes
1
answer
145
views
Reuse same code for validation and runtime integrity checks?
Scenario
I have a system where a user can upload an Excel file which is validated and then used to provide data for the application.
There are two distinct operations I need to handle with this file:
...
0
votes
1
answer
741
views
Validation in both controller and my service classes?
I use the Laravel framework.
I've got controllers, like CustomerActivityController, and I've got a service layer with services like CustomerActivityService.
Say I want to create a new customer ...
0
votes
1
answer
203
views
Serverside validation in a web application
Suppose I have a web application that processes a request as follows.
A user fills in a form and submits it. (e.g., to register as a new user for my application)
The request is passed to the ...
2
votes
2
answers
4k
views
Should you limit the size of JSON array to avoid abuse? Or is this already covered by size limits?
I'm working with a basic REST API, through user interaction on the UI, the JSON object is built up, including Arrays and a POST is sent to an endpoint using this object as the request body. For ...
1
vote
1
answer
3k
views
How to handle duplicate validation logic with CQRS pattern
I am implementing a CQRS pattern in ASP.NET Core with MediatR, and I am wondering what the general consensus is for handling duplicate validation logic for queries/commands which operate on the same ...
0
votes
3
answers
2k
views
CRUD service with or without DTOs
I'm about to create a service providing a simple CRUD Json REST-API. The main requirement is that documents stored/received always conform to a schema provided as JSON schema. So here's the thing:
...
0
votes
3
answers
1k
views
Should I perform simple validation (not null, max length, etc.) in a web api controller and duplicate in a command handler?
I have a question about DDD. I wonder if I should add validation in a web api controller and duplicate it in a command handler? Is it good approach to validate a DTO and a command even if the ...
3
votes
2
answers
2k
views
Maintaining referential integrity between Aggregate Roots
In his book "Implementing Domain-Driven Design" Vaughn Vernon suggests to reference aggregate roots only by ID. I see the following advantages of this approach:
It is clear where the ...
4
votes
2
answers
2k
views
Should similar standalone functions go in a class?
I'm working to create a library in python that myself and a few colleagues will use. I'm struggling to conceptually understand how to best organize some code that feels like it doesn't cleanly fit ...
2
votes
2
answers
92
views
Should client application clean the data that a server application can not internally process? (In SOA Systems)
Scenario :
For some (comment) text field the server application is internally throwing errors when the field contains contains some specific characters.
Where should the removal of characters be ...
0
votes
1
answer
433
views
Should i specify that my methods "throws ConstraintViolationException" if the exception is actually thrown by a CDI interceptor?
Here is a sample method:
@ApplicationScoped
public class MyClass{
public void getUser(@Min(1) int id){
//get User logic
}
}
I'm in a CDI environment with @ValidateOnExecution(type = ...
0
votes
1
answer
297
views
Should I cache database requests made in validation layer?
Imagine an http request in a RESTful API that needs to request the database to perform validations before proceeding, but some of those database requests would need to execute again if the validation ...
2
votes
1
answer
1k
views
Static validator in DDD value objects
I have a value object to hold a user id number as a string. This number has a unique format throughout my domain. So, it's being validated inside the object during instantiation and an exception is ...
3
votes
1
answer
2k
views
Data validation between microservices
Consider a scenario (in .Net Core world), where a microservice A collects data from external sources and sends this data asynchronously (RabbitMQ) to microservice B (the reporting system) where this ...
0
votes
0
answers
75
views
How to validate against changes to "illegal paths" in backend requests for complex data structures?
We are building a backoffice web application where people are making changes to an array of nested objects. Because of totally non relevant business reasons there are things that users cannot change ...
11
votes
4
answers
8k
views
Is it a bad idea to do validation in the constructor?
Consider the following approach to validation of an API class (POJO or what have you, I mean a class which just acts as a container for some properties), we make all constructors private to the API ...
1
vote
2
answers
596
views
Eliminating duplication of validation metadata in client and server
I tried to find some insight in how to handle the duplication of client-side and server-side validation in my app. If, for example, I have an User Entity like this on my back end:
type User struct {
...
-1
votes
1
answer
139
views
Client side validation with Jquery - MVC C# app
I am working on a very LEGACY MVC App using C# which is built from 2009. They dont have any client side validation at all. In other words, they dont use Validation mechanism provided by MVC framework ...
0
votes
0
answers
43
views
Design a multiple Asp.Net Core apps Solution
I am having an .Net Core Solution consisting of 3 Projects:
The Site (Asp.Net Core MVC WebApp)
The API (Asp.Net Core API)
The "Common" library for shared functionality.
The Common library ...
2
votes
3
answers
3k
views
Best practice with error messages say what is wrong, or how to remedy the error?
I've had a quick search and probably explaining the situation is why I can't find anythign useful to help me. It's best to describe the sitation with an example!
Take a form where a user must input a ...
4
votes
1
answer
5k
views
Sharing form validation rules between backend and frontend (Having single source of truth)
I'm currently working on a web app using ASP.NET Core (C#) on the backend and Next.js (TypeScript) on the frontend. I have a lot of forms that need to be validated and I don't want to write validation ...
0
votes
2
answers
2k
views
How to handle validation errors from API response when using repository pattern
I've got the following:
Clientside C# application. Contains forms for CRUD operations. It uses an API for all data operations.
Input is validated on the client, and obviously also on the server (API).
...
1
vote
1
answer
45
views
Failed uploads layer
I am trying to find an optimal way to handle the following scenario:
I have an application where there are a lot of file uploads on a certain endpoint, but the validation is rather strict as per the ...
-1
votes
3
answers
661
views
When and how to check input parameters
My SmsRecipientDetails class constructor accepts String value as recipient phone number.
I would like to accept number with spaces:
assertDoesNotThrow(() -> new SmsRecipientDetails("123456789 &...
1
vote
2
answers
677
views
Identifying states when using state machine to validate a form field
Scenario is simple, a password field with few validation rules.
The states I came up with are
default ( when the form loads or reset button is pressed)
filled ( should this even be a state ?)
valid ( ...
1
vote
5
answers
3k
views
How Much Validation Is Necessary In An API?
What we usually have at work is an API that has a single consumer, usually a SPA web frontend, which is built by the guy sitting next to you.
I completely see the need for authentication and ...
0
votes
2
answers
301
views
Check if can delete before save
I am designing an application that works with REST API requests for dealing with information stored in a database.
The user will add, edit, delete information in this client and after SAVE the ...
1
vote
1
answer
2k
views
Is it considered a bad practice to include methods in classes that comprise an EF model?
I am working on a project that uses Entity Framework Core. I have a class which represents an entity on which I'm trying to perform validation. Is it considered a bad practice to include a Validate ...
2
votes
1
answer
820
views
Best way to handle and combine client side and server side validations
I want to know if the way that I handle form validations is a good way.
What I actually do is a very detailed client side validation to validate each field and with custom error message for the UI ...
1
vote
3
answers
2k
views
DDD Validator Specification with dependency on repository
I have read this https://stackoverflow.com/questions/5818898/where-to-put-global-rules-validation-in-ddd and I have create my validator.
But now I need to create a validator that must check the order ...
2
votes
3
answers
2k
views
DDD - How to validate an entity is valid when said entity is a different domain which i dont have access to
I am wondering how I would validate some actions in my domain when a parameter of an action needs to be validated, but that parameter's entity is actually in a different domain so I can't retrieve it.
...
1
vote
2
answers
535
views
How to manage huge chunks of validation data inside a REST API?
TL;DR What are common practices to separate validation logic inside a rest API & thereby keep the code clean and straight forward? (code example)
Context & Example
Let's say I'm developing a ...
0
votes
1
answer
1k
views
Most appropriate HTTP return code when record locked for update due to invalid data
Context
Typical restful CRUD service, including PATCH method, whose API validates fields (eg the "name" field may not contain digits).
However, data in the database (from backdoor ETL load) ...
2
votes
1
answer
282
views
Event Sourcing/CQRS for Self-Related Entities
I'm building a platform that has an entity named content. There's a clear boundary around what defines content except that it can have relationships with other content entities.
Up until now, there's ...
1
vote
2
answers
214
views
Requirement Verification
According to what I understand, Requirement validation involves going over the SRS to ensure the requirements are correct with respect to the user's needs.
Could you help clarify verifiable ...