Questions tagged [validation]
Tags for questions related to validating data.
266
questions
7
votes
2
answers
5k
views
Guidelines for returning None vs. raising Error for Python string-validating functions
Let's say we have a function that checks if a given pattern occurs in a string. The default behaviour is that if the pattern matches, then it returns the pattern. So far so good but what is the ...
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 ...
2
votes
2
answers
1k
views
ModelState Validation vs JQuery vs Remote
I was stuck with some validations for quite a while. I have been thoroughly searching the internet to find ways to apply the validations I require. I came across many methods for validations even ...
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
1
answer
125
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 ...
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) ...
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
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
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
340
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 ...
2
votes
1
answer
5k
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 ...
28
votes
6
answers
31k
views
In which layer should validation be located?
I'm creating a Rest API using Spring Boot and I am using Hibernate Validation to validate request inputs.
But I also need other kinds of validation, for example when update data needs to checked, if ...
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 ...
0
votes
2
answers
453
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
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 ...
39
votes
9
answers
44k
views
Constructor parameter validation in C# - Best practices
What is the best practice for constructor parameter validation?
Suppose a simple bit of C#:
public class MyClass
{
public MyClass(string text)
{
if (String.IsNullOrEmpty(text))
...
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 ...
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 ( ...
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
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 ...
1
vote
3
answers
1k
views
Best practice in synchronized form data validations (Web apps - Client-Server)
Here we go again with topic what was asked many times all over internet, but I not found any good enough answer:
What are best practices in making client and server side validations synced?
I was ...
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
652
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
820
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.
...
0
votes
2
answers
133
views
Verify That Filters on a Dataset are Exclusive
Suppose I have a data table of, say, cars with a bunch of properties for each record. Example:
|Vin|Year|Make|Model|Color|Mileage|
I want to allow users to define (arbitrarily complex) filters which ...
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 ...
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 ...
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 ...