Questions tagged [validation]
Validation is used to check data to make sure it fits whatever required specifications are set for it.
732
questions
1
vote
1
answer
128
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
2k
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
62
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
29
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
1
answer
58
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 ...
1
vote
1
answer
59
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 ...
1
vote
3
answers
138
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
162
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
98
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
318
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
56
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
233
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
107
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
97
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
64
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
63
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
79
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
407
views
9
votes
4
answers
408
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
173
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
482
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
123
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
198
views
validating form before uploading files
This function below return true/false. How I could possibly improve the code quality?
...
3
votes
2
answers
612
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
75
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
772
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
48
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
94
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
32
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
135
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
99
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
681
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
109
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
983
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
406
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 => ...
5
votes
2
answers
624
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': ...
7
votes
2
answers
3k
views
2
votes
2
answers
1k
views
Laravel controller for form validation skinny
I'm trying to make controllers skinny as possible. I use repositories for accessing the database and I use Services to do other stuff. In this case, I use it to insert a new post to the database. For ...
3
votes
3
answers
294
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 ...
1
vote
2
answers
76
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 ...