Questions tagged [validation]
Validation is used to check data to make sure it fits whatever required specifications are set for it.
728
questions
5
votes
3
answers
675
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': ...
1
vote
1
answer
72
views
Generic function accepting object and validators for this object's fields
I recently started TS.
I was looking for feedback on my below function (for example maybe it can be written in shorter way). Let's assume we still use the reduce ...
0
votes
1
answer
127
views
About self validated Java POJOs
I am currently experimenting with self validating Java beans in order to avoid the creation of objects with invalid states, while keeping the validation knowledge inside the bean. The goals I have in ...
2
votes
2
answers
146
views
Improved input validation function
A week ago I posted this question and after reading the answers and accepting one I decided to refactor my code quite heavily. I would like to get some feedback on this newer version.
The changes
No ...
4
votes
1
answer
91
views
Constructing constrained/validated objects
I'm trying to do some rudimentary DDD in validating my objects to ensure they are of a particular type. I.e. an Email object would always look like "[email protected]" ...
1
vote
1
answer
94
views
Form Validation Code Optimization in HTML and JavaScript"
I've been working on a simple form validation code in JavaScript coupled with an HTML form. The form asks for user's basic information, including name, email, country, gender, and skills. There's a ...
2
votes
3
answers
164
views
Making an input validator function
NOTICE: I refactored the code and made a new question like was advised.
I'm making an input validator function that is inspired by @JDługosz from the following post so that other new C++ programmers ...
1
vote
1
answer
131
views
Validate avatar image
I want to know if that code is correct and readable.
In class avatar the method getAvatar() validates the data. It checks if the field is not empty and if the photo extension is correct. If not, an ...
4
votes
1
answer
3k
views
Swedish 'Personnummer' validator
I have a small C# program that validates Swedish social security numbers ('Personnummer').
I chose to use Regex as there are many different ways it can be input.
...
0
votes
1
answer
84
views
Validate that the console input contains positive integers only
The function validates whether the input is an int, is there a way to make this more concise and is it best practise to use the try/except or just if/else? I then want to create a similar function for ...
-1
votes
1
answer
32
views
Model validation through the combination of PCA with classifiers
I use the code below for building machine learning algorithm.
In the end, I need to validate model performance.
However, I am confused if I do it correctly or not.
...
1
vote
3
answers
202
views
Decorator to validate that Python function arguments are positive
I have a list of functions whose parameters in the signature should be validated with the same criteria each time.
...
12
votes
3
answers
2k
views
Pythonic way for validating and categorizing user input
In multiple parts of my program, user input needs to be validated and categorized. As these "validation trees" can get pretty unwieldy, I've started splitting them out in different functions,...
1
vote
2
answers
169
views
Search/Query API cross parameter check
Background
I was working on a coding challenge as part of an interview process. I had to create a REST API where the user can report sensor data and query derived metrics based on several filter ...
2
votes
1
answer
135
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
0
answers
132
views
Generic custom regular expression with dynamic pattern used as data annotation for Model
I want to apply custom regular expression as data annotation for all of my Model properties.
So I create a custom regular expression with dynamic pattern like below:-
Purpose:- So the purpose of ...
2
votes
1
answer
94
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 ...
4
votes
2
answers
522
views
Given an EAN-8 or an EAN-13 code, tell if that code is valid
I have the requirement to validate product codes which include EAN-8, EAN-13 and UPC-A encoded as EAN-13. I have implemented a use-case to perform this check by comparing the actual check digit with ...
0
votes
1
answer
63
views
Fill TextBox from ListBox on click
I have a form in a WinForms application that has a Textbox called txtSupplier, a button called btnSrchSuppliers, a label called <...
3
votes
3
answers
312
views
Input validation of a signed double (in C++)
I am a beginner, who is just learning the language (C++) from C++ Primer. I have been trying to build a side pico-project by writing functions for validation of user input for an signed double. The ...
1
vote
1
answer
110
views
Theme picker for Laravel 8 blogging application
I am working on a blogging application in Laravel 8.
The application supports themes. In a nutshell, theme support works like this:
In the views directory, I have ...
1
vote
0
answers
149
views
Set-new-password form, including validation
I've got to make a form using Bootstrap and Angular, which validates the following requirements:
Old password, new password and confirm password are mandatory fields.
New password has to be equal ...
2
votes
1
answer
5k
views
Server side validation for reCAPTCHA V2 or Invisible reCAPTCHA with Java (Servlet)
The main reason for this post is that I spent quite a lot of time searching the easiest way to validate recaptcha V2. So I'm going to share my knowledge to avoid further time wastage of developers.
I'...
1
vote
0
answers
68
views
Check that inputs are valid dates
I have a method in a class that accepts either a datetime or string parameter. It is shown in the last code block (I didn't include the class). A little background is that I am defining a wrapper ...
0
votes
1
answer
79
views
Validate 10 digits on a few conditions
I want to write a function that validates the German tax identification number (Steuer-ID).
The identification number consists of eleven digits. The last digit is ...
2
votes
2
answers
96
views
Function to validate that an email address meets some requirements
I want to create a function that checks if an email has a username that is 5 to 20 characters long, starts with an alphabet letter and ends with one domain names of (.org, .net, .org). It also ...
8
votes
3
answers
7k
views
Checking for Roman numeral validity
I am working on a Roman numerals calculator. For an input validity test I'm using this function:
...
0
votes
0
answers
2k
views
Unit testing / TDD MediatR Queries and Validators
I would like to get a code review for the following code. It's meant to filter mocked products. I used to not like writing tests, but some time ago I realized how great TDD is. Not only it makes the ...
2
votes
2
answers
487
views
9
votes
4
answers
421
views
Compact VBA Validator for Excel Names
Update
After examining the NameRulesUnicode64k.xlsm spreadsheet in excel-names, it appears that my NameIsValid() is in close ...
4
votes
0
answers
174
views
Vuejs - input validation
I'm in a project that's currently using vue. I'm at the moment developing validations for the inputs and in a way to make them more flexible, my idea was to create an intermediate component "...
1
vote
1
answer
80
views
Dont let duplicated values in Iterator return of a function
I'm trying to build a function to return an Iterator with no duplicated float values, its working, but there is a better way of handling this duplicated values?
...
4
votes
1
answer
572
views
Python function: user input to get positive integer using assert
Is it a bad thing to use asserts to validate user inputs? Or should I keep using an if statement in case the number isnt positive?
Code with assert statement:
...
3
votes
1
answer
136
views
Take in 10 numbers, validate each input, append then in a list and then prints the sum of the list values
I'm practicing loops in Python and started trying to have a better approach with user inputs, is there better ways of dealing with inputs when coding?
And I tried using deques too, it worked very well,...
2
votes
2
answers
206
views
validating form before uploading files
This function below return true/false. How I could possibly improve the code quality?
...
3
votes
2
answers
619
views
PHP class to send CRM records to Five9 API
I am experimenting with the Five9 API and setting up a PHP class to deal with the addRecordstoList method.
The main issue this class was meant to solve over the traditional function found in their ...
1
vote
1
answer
77
views
JS function to check if a date is in the correct format
I wrote the following JS function to check if a date comes in the right format and can be used further down in the application
...
7
votes
2
answers
848
views
OOP PHP form builder with validation
Yes, another PHP form builder... I wrote this solely to demonstrate OOP principles.
My questions are:
Could this be written better? OOP-wise.
How could I better implement error handling?
Index.php
<...
1
vote
1
answer
49
views
UPDATE on 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: UPDATE 1 on Newspaper ...
2
votes
1
answer
100
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 ...
0
votes
1
answer
31
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 ...
-1
votes
1
answer
33
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 ...
3
votes
1
answer
143
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
101
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
722
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 ...
4
votes
2
answers
5k
views
PHP Validate JSON objects with a JSON schema
I have a basic JSON API written in PHP. I want to validate incoming JSON data.
I know there are PHP JSON validators out there, here is a quick one I just rolled up.
...
3
votes
2
answers
111
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
2k
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 ...
1
vote
1
answer
1k
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 ...
1
vote
1
answer
498
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 => ...