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
0 votes
1 answer
63 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 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. ...
vdu16's user avatar
  • 1
1 vote
3 answers
142 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
  • 209
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,...
Jan van Wijk's user avatar
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 ...
Peter Csala's user avatar
  • 8,420
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 ...
TAHER El Mehdi's user avatar
0 votes
0 answers
99 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
320 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
57 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
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 ...
Razvan Zamfir's user avatar
1 vote
0 answers
102 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,138
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 ...
Travis DePriest's user avatar
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 ...
Daniel's user avatar
  • 219
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 ...
Taylan GÜNAY's user avatar
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 ...
nop's user avatar
  • 719
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 ...
user avatar
2 votes
2 answers
407 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
483 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
124 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
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 ...
SogaBan's user avatar
  • 53
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 ...
Greg's user avatar
  • 359
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? ...
Jefferson's user avatar
  • 357
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 ...
Jakub's user avatar
  • 271
7 votes
2 answers
775 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
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 ...
eccentricOrange's user avatar
-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 ...
George's user avatar
  • 1
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 ...
frIT's user avatar
  • 153
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 ...
eccentricOrange's user avatar
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 ...
eccentricOrange's user avatar
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 ...
SDRJ's user avatar
  • 161
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. ...
True do day's user avatar
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 ...
Adriaan's user avatar
  • 55
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 ...
Incomputable's user avatar
  • 9,374
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 => ...
Enrique's user avatar
  • 145
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 ...
user254603's user avatar
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 ...
user avatar
0 votes
1 answer
105 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
80 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
1 vote
1 answer
196 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
987 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
2 votes
2 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
76 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
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 ...
Vesa95's user avatar
  • 133
3 votes
1 answer
348 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
239 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
4 votes
1 answer
315 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, ...
Max's user avatar
  • 41
7 votes
5 answers
139 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. ...
Jon Grey's user avatar
7 votes
3 answers
765 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 ...
Kushagr Jaiswal's user avatar
1 vote
3 answers
96 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, <...
user9437856's user avatar

1
2 3 4 5
15