Questions tagged [validation]
Tags for questions related to validating data.
266
questions
0
votes
0
answers
27
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
94
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 ...
1
vote
2
answers
184
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 ...
0
votes
1
answer
131
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
126
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
143
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 ...
2
votes
2
answers
176
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
159
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
68
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
172
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
107
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
171
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 ...
2
votes
1
answer
341
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
28
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 ...
7
votes
3
answers
1k
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 ...
0
votes
2
answers
63
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
35
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
23
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 ...
0
votes
3
answers
199
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 ...
1
vote
1
answer
1k
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
454
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
33
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
68
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
148
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 ( ...
0
votes
5
answers
621
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
140
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 ...
0
votes
1
answer
283
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 ...
1
vote
1
answer
229
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 ...
0
votes
3
answers
653
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 ...
1
vote
3
answers
822
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
190
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
317
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
185
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
164
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 ...
2
votes
2
answers
503
views
Entity delete validation in a microservice environment
In a microservice environment there are two services: Service A and Service B.
Service A manages an entity called x which has one to many relationship with service B's entity called y
When a network ...
1
vote
1
answer
162
views
Can I put domain services inside domain entities?
Say I have a domain entity User:
class User {
constructor (username, email, password) {
this.username = username
this.email = email
this.password = password
}
}
Now, all users need a ...
2
votes
0
answers
295
views
Layers of validation for clean architecture in .Net Core web application
For a clean architecture where there is presentation layer (Javascript), web api layer, application/domain layer, infrastructure layer (EF Core ORM). Let's say it is an ATM system and the use case/...
4
votes
1
answer
2k
views
DDD and MediatR - where the Validation and Business Logic go
I'm trying to get to grips with Domain Driven Design and MediatR. A reaction to being involved with applications that favour Services for almost everything. I see so much value in DDD and I'm trying ...
1
vote
3
answers
1k
views
Where to validate user input - Constructor, Validation object, or Factory method?
Let's say your application takes in a user request and you don't trust the front-end validation (because you never trust the front-end validation). In your controller or other handler, you want to ...
43
votes
8
answers
8k
views
Is it common practice to validate responses from 3rd party APIs?
I'm working on a PHP web application that depends on a few 3rd-party services. These services are well documented and provided by fairly large organisations.
I feel paranoid when working with ...
1
vote
1
answer
2k
views
How to handle input validation in microservices for duplicated data
What would be the best practice of handling input validation in microservice? Especially for the duplicated data?
To give context, say I have 3 services:
User
Typical user service with User object ...
0
votes
1
answer
170
views
DDD - Complex value object
I have a Message class that represent some data sent by a smartwatch. A Message has a header (sender, length...) and a type; it can be a location update, an alarm message... There are about thirty ...
1
vote
2
answers
417
views
How to avoid duplicate data validations ( checks ) in web applications?
I'm learning about Software Architecture and especially about scaffolding large-scale architecture and patterns for modern web applications.
I've noticed that I don't have a pattern for data ...
1
vote
1
answer
112
views
Validation framework and immutability
I have designed a simple objects validation framework in Java in the context of a code refactoring.
The framework has a ValidationRule interface with one method Errors validate(MyObject myObject, ...
1
vote
1
answer
48
views
Still catch "duplicate entry" exception of database even after pre-validation of user input?
Say, you pre-validate if a username already exist in a registration form in the application layer. E.g., You send back a nice "username already exist" error message to the user.
While unlikely, there'...
1
vote
3
answers
2k
views
What http error to return in case of validation and business rules in a domain driven design api
I have a .net core api trying to implement it according to domain drive design principles.
In the domain layer there is a public Create method that contains all validation and business rules. If one ...
1
vote
1
answer
153
views
Independence axiom and ideal design explained
I am studying a book about software design called: Nonfunctional Requirements in Systems Analysis and Design which talks about the Axiomatic Design Methodology.
This methodology has two axioms. One ...
1
vote
2
answers
2k
views
How to Validate a Child Object Based on Parent Object's Data
Taking into consideration that I'm making an attempt at Domain-Driven Design and overall good separation of concerns when it comes to business logic, data access logic, etc...
Question: How do you ...
1
vote
1
answer
851
views
Domain Driven Design Validation Logic
I am trying to implement DDD along with Hexagonal Architecture. One of the things that I am struggling with is validations. I had explored a lot of articles on where the validation should be but it ...
2
votes
4
answers
226
views
Is it a bad practice to query remote resources inside validation?
Watching this talk about Symfony Forms and validation, at 23:06, I got stuck with a doubt
I couldn't find a satisfying answer to:
Is it a bad practice to execute a query (or a web request, or a side ...