Skip to main content
Share Your Experience: Take the 2024 Developer 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
3 votes
1 answer
46 views

Check if options are valid to create FAT12 image

This is a function that checks if a valid FAT12 image would be created. Since all the information to create it is available on the "boot sector", this is the parameter. I wanted the code to ...
Schilive's user avatar
  • 243
1 vote
1 answer
313 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 ...
silver_mx's user avatar
  • 119
2 votes
2 answers
161 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 ...
globalturist's user avatar
2 votes
3 answers
179 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 ...
globalturist's user avatar
0 votes
1 answer
192 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 ...
Luca's user avatar
  • 57
1 vote
1 answer
49 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. ...
vdu16's user avatar
  • 21
1 vote
3 answers
421 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. ...
SeF's user avatar
  • 199
12 votes
3 answers
3k 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,...
Jan van Wijk's user avatar
1 vote
2 answers
177 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 ...
Peter Csala's user avatar
  • 9,209
1 vote
1 answer
126 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 ...
XMehdi01's user avatar
  • 523
2 votes
1 answer
228 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 ...
CodeJoker's user avatar
4 votes
2 answers
1k 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 ...
Droidman's user avatar
  • 153
0 votes
1 answer
98 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 <...
user10191234's user avatar
1 vote
1 answer
118 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 ...
Razvan Zamfir's user avatar
2 votes
0 answers
238 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 ...
michael.zech's user avatar
  • 4,358
1 vote
0 answers
69 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 ...
Travis DePriest's user avatar
0 votes
1 answer
114 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 ...
Daniel's user avatar
  • 229
2 votes
2 answers
136 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 ...
Taylan GÜNAY's user avatar
2 votes
1 answer
92 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 ...
user avatar
2 votes
2 answers
638 views

Apply a schema validation against an HTTP request with JSON body

...
Cengiz Ergün's user avatar
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? ...
eddyxide's user avatar
  • 141
4 votes
1 answer
675 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: ...
eddyxide's user avatar
  • 141
3 votes
1 answer
153 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,...
eddyxide's user avatar
  • 141
3 votes
3 answers
446 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 ...
SogaBan's user avatar
  • 53
9 votes
4 answers
448 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 ...
Greg's user avatar
  • 403
2 votes
2 answers
226 views

validating form before uploading files

This function below return true/false. How I could possibly improve the code quality? ...
Jefferson's user avatar
  • 353
1 vote
1 answer
84 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 ...
Jakub's user avatar
  • 271
7 votes
2 answers
942 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 <...
PRobert's user avatar
  • 73
1 vote
1 answer
51 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 ...
eccentricOrange's user avatar
-1 votes
1 answer
38 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 ...
George's user avatar
  • 1
0 votes
1 answer
32 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 ...
frIT's user avatar
  • 153
3 votes
1 answer
152 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 ...
eccentricOrange's user avatar
2 votes
1 answer
107 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 ...
eccentricOrange's user avatar
5 votes
2 answers
793 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 ...
SDRJ's user avatar
  • 161
3 votes
2 answers
112 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. ...
True do day's user avatar
1 vote
3 answers
3k 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 ...
Adriaan's user avatar
  • 55
2 votes
1 answer
127 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 ...
Incomputable's user avatar
  • 9,504
1 vote
1 answer
687 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 => ...
Enrique's user avatar
  • 145
1 vote
1 answer
141 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 ...
user254603's user avatar
2 votes
2 answers
83 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
112 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. ...
user13477176's user avatar
1 vote
2 answers
92 views

my idea of validating data and bussiness logic

I'm experimenting with some variations of validation pattern. I've created Validator class: ...
Mateusz's user avatar
  • 113
2 votes
1 answer
263 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 ...
Jake Feeley's user avatar
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 ...
Zikri Munandar's user avatar
3 votes
3 answers
2k 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 ...
flamethrower10's user avatar
3 votes
2 answers
99 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 ...
Khaled Sayed's user avatar
3 votes
3 answers
667 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 ...
Vesa95's user avatar
  • 133
3 votes
2 answers
154 views

Image upload filter for PHP

I am trying to improve my file upload handler filter. Environment Since any client-side validation is easily circumvented, there is none in this code, for ease of testing. Not even an ...
JoSSte's user avatar
  • 199
3 votes
1 answer
445 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 ...
hibih's user avatar
  • 55
1 vote
2 answers
249 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 ...
C4Oc's user avatar
  • 19

1
2 3 4 5
15