Questions tagged [validation]
Validation is used to check data to make sure it fits whatever required specifications are set for it.
719
questions
-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 ...
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 ...
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 ...
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 ...
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 ...
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.
...
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 ...
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 ...
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 => ...
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 ...
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 ...
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.
...
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:
...
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 ...
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 ...
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
...
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 ...
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 ...
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 ...
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 ...
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, ...
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.
...
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 ...
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, <...
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 ...
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 ...
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, ...
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 ...
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 ...
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 ...
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 ...
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 ...
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': ...
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 ...
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 ...
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 ...
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
...
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'...
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:
<...
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 ...
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, ...
3
votes
3
answers
224
views
Email Validation in PHP
Is this script sufficient enough to validate user email input?
...
-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 ...
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?
...
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 ...
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 ...
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 ...
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 ...
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 ...
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/...