Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Questions tagged [validation]

Validation is used to check data to make sure it fits whatever required specifications are set for it.

Filter by
Sorted by
Tagged with
-1 votes
1 answer
24 views

Validation rules for payment cards in a data set

I have the following part of code. I dislike this, because if I need to add additional validation rule, I have to make changes in loop and create a varaible to store boolean result. For example check ...
user avatar
  • 1
0 votes
1 answer
26 views

Validating with both a field validator and a form valdator

This (minimal demo) code obviously works, but I am a bit taken aback by the hoops I needed to jump through (and little to no mention in Angular (v13) documentation about the technique). I'm still ...
user avatar
  • 153
3 votes
1 answer
87 views

Newspaper Bill Calculator CLI with Python (2 of 3, CLI)

Code is posted after explanation. Due to the size of the project, this is being posted in three separate posts. This also ensures each post is more focused. Post 1 of 3, Core: Newspaper Bill ...
user avatar
2 votes
1 answer
56 views

Newspaper Bill Calculator CLI with Python (1 of 3, Core)

Code is posted after explanation. Due to the size of the project, this is being posted in three separate posts. This also ensures each post is more focused. Post 2 of 3, CLI: Newspaper Bill ...
user avatar
5 votes
2 answers
276 views

CSV file parser with some checks for header fields and duplicate rows

I have built a sample Parser class on top of the csv module for basic checks that we normally need as the first step of pre-processing. I would love a bit of feedback on the code and any areas that I ...
user avatar
  • 161
3 votes
2 answers
97 views

Multiple condition checking on array-like container in Python

I'm writing a function that validates array-like container to have correct type, length or to be hashable. Some of conditions may not be used for validation. ...
user avatar
1 vote
3 answers
136 views

c# record parameter validation technique

This comes from an answer I provided to a question on stackoverflow here: https://stackoverflow.com/a/71482194/3258131 To make c# record parameter validation concise and maintain all the benefits of ...
user avatar
  • 45
2 votes
0 answers
16 views

Chaining perf with FlameGraph

This is my first serious shell script, so it is probably horrible. Problem statement I decided to improve my profiling skills as so far they were mostly about hand-rolling counters and timers. After ...
user avatar
  • 9,069
1 vote
1 answer
84 views

Best way to do Input Validation on Swift/iOS/UIKit

I have the following form that creates a new "activity": For which I want to enforce the following requirements: Name => minimum # of chars: 1; maximum # of chars: 50 Description => ...
user avatar
  • 155
0 votes
0 answers
65 views

Validate avatar image

I want to know if that code is correct and readable. In class avatar, I make validation. I check if the field is not empty and if the photo extension is correct. If not, an appropriate exception is to ...
user avatar
1 vote
2 answers
65 views

Controller method to store course

I have this controller method to add a course and it works fine but I really don't like this code because I think it's too large and a little bit ugly I was trying to do it cleaner and a little bit ...
user avatar
0 votes
1 answer
90 views

PHP Upload script security

I am creating a social network and part of the features allows people to upload a profile pic. I want to know how secure my code is. From start to finish. ...
user avatar
1 vote
2 answers
68 views

my idea of validating data and bussiness logic

I'm experimenting with some variations of validation pattern. I've created Validator class: ...
user avatar
  • 113
1 vote
1 answer
74 views

Laravel CRUD Controller - code request

Here is my starting point for a laravel CRUD controller. I would appreciate it if someone could do a review and show me how an experienced developer would approach this. I do not want to progress with ...
user avatar
1 vote
1 answer
219 views

Placing store and update logic in Laravel 8 form request

I want some opinions about my code that implements store and update for a Laravel 8 form request. The make function is for storing the data and the ...
user avatar
2 votes
2 answers
382 views

Simple credit card validation with Luhn's Algorithm

Originally written in C (which was abysmal, you may check here if you want), I rewrote my simple credit card validation program using Python ...
user avatar
3 votes
2 answers
53 views

Displaying validation messages for an input form

I'm trying to capture all input fields in a form (i.e. sign_up.html) & validating them - if one of them is null or empty then it should show a validation message. I've done it but I'm looking for ...
user avatar
3 votes
3 answers
194 views

Input Data Validator (good practice)

I work at an application that receives data from user and I try to write a validator function for it, but I'm not sure if this is the correct way to proceed. Example: The user will input a number (as ...
user avatar
  • 133
3 votes
1 answer
199 views

Sanitation and validation of a user input 10 digits phone number

phoneNumberCheck() is using 2 helper function to check if a users input of a phone number is valid. this is a client side check, if this code is ok should I check the same at the nodeJS back end? is ...
user avatar
  • 55
1 vote
2 answers
164 views

Possible speed improvements for a Sudoku board validation algorithm?

I tested this algorithm on 9x9 boards and on average, if the board passed to the function is a (valid) solution, it takes 0.13-0.14 seconds for 1 million executions on my machine. I ran my code in ...
user avatar
  • 19
4 votes
1 answer
74 views

How to make my code shorter. This Code formats Credit card number. Vanilla JS

How to make my script shorter and better? This code allows only digits, auto-format card number like this XXXX XXXX XXXX XXXX. if user hits delete or backspace to delete space in between digits, ...
user avatar
  • 41
7 votes
5 answers
122 views

readable validation with python regex and simple logic

I have come with such a code for checking IP addresses. But would like to know how clean and good it is from 1 to 10. What I care about are readability and simplicity. Please give me any feedback. ...
user avatar
7 votes
3 answers
712 views

Input validation

I am learning C from C Primer Plus, and am still a beginner. I have been introduced to only two functions for input, scanf() and ...
user avatar
1 vote
3 answers
84 views

What is the best way to login according to account type with server-side validation?

I have two access roles as of now for example account_type 1 and 2. What I am doing is, <...
user avatar
2 votes
1 answer
76 views

Recursive type checking for containers

This code checks the type, length and depth (highest number of nested containers) of the container as well as the type of its sub-containers and its elements. There are also two simple methods for ...
user avatar
  • 23
0 votes
1 answer
39 views

optimize integer validation

I have some classes with properties, wich could only have numeric values in a given range (e.g. 0 to 8). This should be validated and wrong values prevented with an exception. The given behavior may ...
user avatar
  • 103
2 votes
1 answer
29 views

Validator and Sanitizer for HTML 5 attribute regex according to current HTML living standard

According to https://html.spec.whatwg.org/multipage/syntax.html#attributes-2 an HTML 5 attribute name is defined like this: Attribute names must consist of one or more characters other than controls, ...
user avatar
  • 137
3 votes
1 answer
147 views

Submitting form jQuery checkboxlist

In my requestForm submit function I have this logic that checks three checkboxes and then displays the label with an error message. Is there better logic? I would be happy for any kind of feedback ...
user avatar
  • 109
1 vote
1 answer
102 views

Advent of Code 2020 - Day 2: validating passwords (C++ version)

Original: Advent of Code 2020 - Day 2: validating passwords Problem statement I decided to translate my Rust solution to Advent of Code 2020 into C++ to increase my familiarity with C++. Here's the ...
user avatar
  • 8,937
1 vote
1 answer
61 views

How can I upgrade my validation in JavaScript?

How to improve my validation in JavaScript? Namely I am wondering whether some parts of code can be shortened, improved, or removed althogether. I don't want to change the ES5 syntax because so far I ...
user avatar
  • 11
7 votes
2 answers
719 views

Simple username validation

This checks if a given username is valid, before doing any database lookups. (I know it's possibly better to use regular expressions, but I wanted to be able to give specific errors.) I'm curious if ...
user avatar
0 votes
1 answer
120 views

Advent of Code 2020 - Day 2: validating passwords

Previous: Advent of Code 2020 - Day 1: finding 2 or 3 numbers that add up to 2020 Next: Advent of Code 2020 - Day 3: tobogganing down a slope Problem statement I decided to take a shot at Advent of ...
user avatar
  • 8,937
5 votes
2 answers
396 views

Chess Dictionary Validator (Python) (Automate The Boring Stuff)

This is an exercise in the Automate The Boring Stuff book. I am supposed to create a function that takes a dictionary argument that represents a chess board (ex: {'1h': 'bking', '6c': 'wqueen', '2g': ...
user avatar
  • 99
2 votes
1 answer
92 views

Suitable way for Validating JPA Entities in Spring Boot

I have been around in Spring Boot eco-system since 2012, I have worked on many little projects. The most important thing in development I experienced id Validation ...
user avatar
2 votes
1 answer
90 views

user-facing email validation

I'd like to have a generic way for validating user provided email with a bias toward ease of use. Does the following do so in a clear way for implementations that have the ...
user avatar
  • 221
0 votes
1 answer
53 views

Attempt on basic input validation and functional programming in a POSIX shell

In spite of all the POSIX shell disadvantages, I am still sticking with it and I love its portability. Recently, I was searching for a way of code re-use, which turns out to be structured programming ...
user avatar
3 votes
2 answers
60 views

C++ PixelComponent struct

Hey I wrote a struct in C++ trying to represent a Pixel Component of a color Here it is ...
user avatar
5 votes
2 answers
219 views

Chess Dictionary Validator from Automatic Boring Stuff with Python

This project is in chapter 5 introduced me to a whole new world of dictionary data structure. To put it briefly, I want to know whether the choice I took between lists, tuples, and dictionaries could'...
user avatar
  • 159
3 votes
1 answer
821 views

Handle database validation (exists, unique constraint, etc) [closed]

Let's assume you are writing a REST Api with a common structure like Controller > Service > Repository > Database. In the database there's a table with a column with a unique constraint: <...
user avatar
  • 183
3 votes
1 answer
105 views

Checking Object keys set with value against another Object keys

I'm willing to check an an object's values in typescript, based on another object's keys. The mental model is "the key exists, it's not an object, is the value in obj set, otherwise, it's an ...
user avatar
  • 175
4 votes
2 answers
87 views

PHP Email List Sign Up

See my original post: here. I have one html page and four php files that allow users to sign up for an email list. One of the php scripts is a cronjob that deletes unverified rows older than 24 hours, ...
user avatar
3 votes
3 answers
224 views

Email Validation in PHP

Is this script sufficient enough to validate user email input? ...
user avatar
-2 votes
1 answer
63 views

Validate Search Binary Tree [closed]

I was looking to this exercise: Is Valid Binary Search Tree I tried to do the exercise by myself without looking to the solution and my code is "much simpler" than the code I found at the ...
user avatar
  • 105
1 vote
2 answers
412 views

Python Regex to validate an email

I have written this regex to validate an email. It seems to work fine. Can someone advise on the regex used? Does it work properly or can be done in a better way? ...
user avatar
  • 169
3 votes
0 answers
46 views

Validating a file input whose value is reset to empty string ("") after selection

My form comprises of a mandatory file input. The form is validated according to the jQuery validate plugin. The file input has attribute required so that the ...
user avatar
  • 131
2 votes
0 answers
36 views

Find Invalid User Relationships in User to Manager Map (validate map as valid tree structure with no circular relationships)

We have a new service where an admin can upload a spreadsheet of new users they want to add to our application. During our processing we make a union map of all the users both existing and new ...
user avatar
1 vote
1 answer
34 views

Check that elements in list follow a specified date-format schema and are not null/na/nan [closed]

I'm practicing some data-analysis and I'm currently checking the integrity of my data. The elements that do not follow my date-schema, should be funneled to a new separate list so I can work on ...
user avatar
2 votes
1 answer
233 views

What is the best way to use serverside validation in PHP PDO?

I have a form on my page. I am using jQuery validation for client-side and PHP for server-side validation. I am using PDO. I don't have any issues with client-side and server-side validation. My form ...
user avatar
3 votes
1 answer
192 views

Secure/Bulletproof Image Upload Using PHP

Here is my code that check and upload an image to my website. Is this code really secure against uploading of malicious codes? Anything I have to add to this code to make it more secure? I have also ...
user avatar
  • 31
13 votes
4 answers
2k views

C Program which compares software version strings

I wrote the following C program to compare software version strings. Please provide any general feedback you'd like, but with special focus on error handling decisions, user input validation/...
user avatar
  • 1,323

1
2 3 4 5
15