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
4
votes
2answers
45 views

A C# struct representing a string that can be neither null nor white space

I've written a C# struct in order to encapsulate the idea of a string being neither null nor ...
4
votes
4answers
1k views

UPC-A validation

I've just written a validation routine for a UPC-A, which ensures the check digit matches the given UPC number (according to rules I found on Wikipedia). Below is the code, what do you think? ...
0
votes
0answers
25 views

Just a simple Rspec test comparing parent class/model account_id prop [closed]

I need to refactor this code to use ****rspec subject, let and it methods**. So i need subject of testing, and declaring vars with rspec let method.** I also need to create new instances of Classes/...
1
vote
0answers
13 views

Manipulate urls with regular expressions instead of the slip approach

Basically I have an url which looks like this structurally speaking: http://www.my-site.com/topic1/topic2/topic3/topic4/topic5 and I want to do 2 things to it: <...
3
votes
0answers
32 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 "my@example.com" ...
7
votes
1answer
2k views

Credit card validation - Python 3.4

Just completed a piece of code - a credit card validation program in python - as a little side project. Having no experience with classes in the past, I decided to employ classes in this project. I ...
3
votes
1answer
34 views

Validate URL with Regex and java.net.URL

I'm writing a URL validator. Firstly, it checks for special characters in the input. Secondly, it adds 'http://' and checks for validity. ...
0
votes
2answers
79 views

Python code to continue if a certain type is seen, otherwise try again to get valid input [on hold]

I am very very new to programming, and this is my first day using Python. I want to check to see if an input is of type 'int' and to proceed with my program if the user has entered an 'int', ...
2
votes
0answers
35 views

Ensuring a valid JavaScript string in security-critical application

I'm writing an application where users can write custom expressions which are then converted to JavaScript functions and executed. The expressions are used for filtering and sorting data from a ...
2
votes
1answer
27 views

Conditional validation for credit card payment information on form submission

This is the piece of code I'd like to refactor. Basically, when the credit card option is selected, then do I want the credit card number, zip code, and Cvv inputs to be validated. ...
1
vote
1answer
56 views

Ensure multiple steps work/saving multiple models via a service

I just thought of something new re: saving multiple objects in Rails (though Rails is not necessary). Objectives: Create an author and a tomato, but both of those must be valid. If invalid creation, ...
2
votes
1answer
47 views

TypeScript 3 form validation object

Please, correct me with anything that I say in here (The actual question is below the code). I've been quickly prototyping a project (ASP.NET Core 2.1) and haven't found the need to structure it with ...
4
votes
1answer
67 views

Regex XML validator

I have written a Regex to validate XML/HTML, along with any attributes. It aims to: Match any XML-like text Not match any unclosed tags Adapt for any spacing, newlines, etc. Be as generous as ...
10
votes
4answers
658 views

Repetitive validation of Console inputs

I have this code that asks the user for inputs and validates the inputs if they are Integers (no other inputs are allowed). I'd like to ask for some help in terms of elegance of the code or ...
5
votes
3answers
626 views

Chess move validator

I have written code for making a Chess Validator, which will validate the moves of a chess game. There is a Main class which is taking the input from the user, about the move. Problem Description ...
7
votes
3answers
334 views

IP4 strings validator

Trying to write fast non dependency IP4 string validator for embedded system, It should counts leading zeros, values over 255 and other corrupted strings. Not sure if I missed something. Сan you guys ...
5
votes
1answer
3k views

Class-based user input validation

Having contributed to this Community Wiki on StackOverflow regarding validating user input, I thought I'd finally sit down and write something more robust to do these kinds of tasks. I wanted ...
7
votes
1answer
54 views

Infix to postfix conversion in C++

Here is a program for conversion of an infix expression to a postfix expression using a stack. I would like to know how I could improve my checking for invalid input, make my code more expressive, and ...
3
votes
0answers
29 views

Form deserializer for Python Flask

I've started working on a small Flask project for no real reason other than fun, and pulled myself back on form validation. I realize that there are existing libraries like WTForms, but wanted to try ...
3
votes
1answer
36 views

Validating partially filled objects

The following classes are a simplification of an auto-generated code of an ORM (targeting Microsoft's Dynamics CRM): ...
2
votes
1answer
95 views

Form validation function for React

I need to validate multiple input fields using React. I am using a simple if-else block for each input field but I would like to optimize my code and make it better. I feel there can be a better way ...
6
votes
2answers
140 views

Asynchronous IBAN API with validation

I am working on an iban api which is about saving the iban of some members after (iban validation) in a database. The code is split between Domain (entities, behaviour for iban validation), Database ...
27
votes
2answers
22k views

Password checker in Python

Using Python 2.7.12 I wrote a simple little script, psk_validate.py, that prompts the user for a potential password and checks if it has upper and lower-case ...
3
votes
2answers
56 views

Checking the strength of a password using regexes

I'm a beginner in Python and I made a password checker. I'm following these rules: I have to use regex password must be at least 8 characters must have at least one lower case character must have at ...
1
vote
1answer
39 views

Integer field in Python with extra constraints (Testable class)

I am trying to write an integer field in Python with the following attributes: Minimum Exclusive minimum Maximum Exclusive maximum Multiple of Value Basically, given the constraints and the value, ...
3
votes
1answer
418 views

Calling a Luhn check function when a credit card field changes

I feel like I should not be duplicating the code to gather the credit card number, but I am not sure how best to do it. Any suggestions? ...
0
votes
1answer
31 views

Upload image with GD library

First of all I just started learning OOP. My priority is to make safe code. I think my code is safe, because I use GD to make a copy of the uploaded image and I use an image proxy to make sure nobody ...
1
vote
0answers
41 views

React.js hook to validate a form on submission

I am fooling around with hooks in React and I'm stumbling against decisions that I need to make regarding implementation. Below is the code for the custom useForm hook which can be used to hook up ...
2
votes
0answers
41 views

jQuery validation for multi-page registration form

I use JS/JQuery validation for radioboxes, input field etc. Because of AJAX I use one global validation (in a separate file) and 4-5 other files to coverage actions in a relevant registration form ...
2
votes
1answer
157 views

Checking if an object meets certain criteria to amend to certain Entity Objects?

I am trying to check if a class has only numeric values in it and then return a bool, however, some instances there may be non numeric chars in an object that ...
0
votes
1answer
49 views

Generate an ID number for each new row of text that is pasted into the worksheet

This code checks if "B2" and so on is filled in and if it is then it will generate a new ID number for the row of data that was transferred to the worksheet on the next empty row, I know this code ...
6
votes
3answers
285 views

Simple object validator with a new API

Quite some time ago I have created the Simple object validator (see also self-answer). The more I used it the more I thougt its API could be better so I have heavily refactored it and would like to ...
2
votes
0answers
33 views

Range validator for multiple types

I have an existing overloaded set of functions that I cannot change and need to be tested: ...
6
votes
1answer
87 views

Simple function to create Tokens from user input

I am new to programming in Rust and as an exercise I was making a simple Lottery checker program. It has a simple menu, the user enters a number for the corresponding option such as 'Add a line', '...
7
votes
3answers
907 views

Fluent Validation of Objects

Inspired by this question by t3chb0t and as an elaboration of my own answer, I have written the following solution. My goal was to reduce complexity both in implementation and use. Eventually - I have ...
7
votes
2answers
18k views

Bank account number validation in IBAN format

I wrote a JavaScript function for validating bank account numbers in IBAN format for my own joy. Could you have a look if you don't see any obvious mistakes or places for improvement? ...
2
votes
0answers
73 views

Pricing data checker script

I was recently given a task to implement a data-checker script which given an input file containing (date, last_price) values should check for 3 different kind of errors - missing values, stale values ...
3
votes
1answer
55 views

Servlet to let a user download a file

Is the code below an efficient way to get the zip file from the server? The code works fine but I'm wondering if I should throw some exceptions for the following conditions: ...
1
vote
1answer
60 views

Sign-up serialization in Python [closed]

I built a small project using Django-Rest-Framework. Please comment on the best practice style for the code below, which will make it simpler. ...
2
votes
2answers
68 views

Validating that a Java program has two equal-length arguments

I'm writing a small almost one method Java class for a job application and the advice given was to write it as though it was a piece of commercial software. The ...
5
votes
1answer
116 views

Ship placement verification function for Battleship game

I wrote a server-side Battleship game simulator in nodeJs/Javascript: A random player who begins is chosen. Both players place their ships. Software recognizes if they are placed correctly. One of ...
4
votes
0answers
41 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 "Group ...
5
votes
1answer
81 views

PHP program to validate phone numbers from a file

As part of job interview, I was asked to write a cli script that takes a list of phone numbers to validate from a file and as an option in the command line. It will then produce a CSV file with three ...
3
votes
1answer
49 views

checksum hash verification functions for bash scripts

just a little script, or a bit of a template of one that I used to submit an assignment. I believe it all works fine, I just wanted to give it to other people, and get some feedback on it; maybe make ...
5
votes
1answer
52 views

Add-in for input() with validation

What do you think about this code? Do you have some advices and remarks for me about them? I have started learning python recently. ...
6
votes
2answers
3k views

Age verification module in Python

I wrote an age verification module in Python 2.5 . How can I improve on current_year? import time perhaps? ...
0
votes
1answer
108 views

Chaining ConstrainableSet<T> [closed]

Based on feedback on my previous question, I made many small adjustments to the code, added more APIs and tried to follow through with delivering on the excellent advice I have received in regards to ...
1
vote
1answer
100 views

Read in a file, check that it meets certain criteria

This was my original posting: Check that a data file contains the expected number of rows and columns of integers I updated the code. Still what could I improve on? Another question I have is how ...
3
votes
2answers
63 views

POSIX shell function for asking questions

I've written a tiny function for asking questions intended for my POSIX shell scripts, where I often need user input. The function takes 2+ arguments, where: Is a string containing the question. , 3....
2
votes
1answer
172 views

Filtering and Validating value in SETTER

I have been working on a side project for input filtering/Validation. First I would like to go over my interface. ...