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
1
vote
0answers
72 views

JSON validator using rules

I'm writing an application that is meant to validate data. The data comes in the form of JSON and I'm using JSON Schema to validate the structure and some of the logic along with functions to ...
1
vote
0answers
258 views

Using repository in a FormRequest in Laravel for custom business rule validation

This is my app/Http/Requests/Organisation/CreateOrganisationRequest.php ...
8
votes
2answers
2k views

Checking some rules before a Telegram bot replies to a message

So far, I've created a couple of programs, and the issue that comes up is how ugly and non-scalable they look. For example, currently I'm working on a telegram bot. Before replying to a message I ...
5
votes
2answers
9k views

Conditional validation on two input fields that depend on each other

My code consists of two input fields and a submit button. The business rules require the following rules: At least one field must be filled out. Both can be filled out but both cannot be blank. If ...
3
votes
1answer
720 views

Credit card validator code in Python

I wrote a Python code that is validating Credit Card Numbers. Some of the advanced programmers told me my whole code is messy. How can I make my code cleaner? ...
3
votes
0answers
201 views

Define a class for latitude and longitude in C++ using boost::units and spheroidal coordinates

I am trying to write a class that defines latitude and longitude in C++ using boost::units and normalized spheroidal coordinates. I want to throw an exception if ...
3
votes
2answers
2k views

JSON Schema Validation helper method

This is what I wrote to validate JSON to the given schema. ...
3
votes
1answer
95 views

Function to validate data using up to four kinds of rules

Sometimes I end up with a function that requires checking multiple conditions to determine the outcome and the logic can get to be too much to handle on a single line. Here's an example of how I ...
2
votes
1answer
4k 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
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
3answers
2k views

Integer validation in C++

I am studying C++ and after I learned about some functions of the library cctype like isdigit I decided to make a program that ...
1
vote
0answers
192 views

A rails controller needs to validate certain values exist

I need to pass some values from a CMS to a rails view. I should check these values are defined in the CMS. These values are meant to be use in all pages, hence the use of ...
-1
votes
1answer
35 views
-3
votes
2answers
103 views

Check if a variable is one of a set of valid strings [closed]

We need to check if a given variable is either "get" or "post". If it's neither then I should throw an error. My teammate and I ...
22
votes
6answers
8k views

Validating Yes/No answers in C++

I intend to accept all of the following answers: y Y yes YES Yes plus mixtures, such as yeS, yES, which I didn't intend to accept but it's a consequence of my code the same applies to No and its ...
2
votes
3answers
283 views

Validation of Identification card fields (string and array)

I am validating two variables of an Identification card (cedula in the code). The first one is a string and the second is an array. My inputs are: 1- e.g. ...
5
votes
2answers
222 views

Address form validation

I need help with this code. How can I make it shorter? How can I create an array with the names, for example, errors, and modify code without so many If statements? ...
2
votes
1answer
70 views

Validating list of values to be sent to API

I'm currently writing a client library to use with a courier's SOAP API to create and manage shipments. I'm using the service classes generated from the WSDL provided by the courier, their ...
3
votes
1answer
174 views

Custom exceptions for validating movie information

I wrote my first application about custom exceptions and catching them. Here is the GitHub link. I Have 3 types of custom exceptions: TimeException (validate time: hours, minutes) MovieException (...
0
votes
1answer
651 views

Inputs equality check using jQuery without plugins

I tried creating a function to check for a match between two email fields, let's say EMAIL and CONFIRM email. I absolutely try to avoid jQuery validate. It is not worth it for a single field. For the ...
1
vote
1answer
332 views

jQuery looping on fields after validation

I have the following code: ...
4
votes
1answer
170 views

Simple form validation module

Thinking about form validation, I just wanted something simple that works and is extensible. I came up with the following code, which expects a list of selectors that maps to one or more functions ...
-1
votes
2answers
123 views

Verifying that all fields of a unit has been suitably filled in

I have unit class which have some properties, and I have acceptancePolicy table which contain values. If values (from one row) are true method should return true. The method is below. How can I ...
17
votes
6answers
9k views

Simple object validator

I wrote a simple validation tool that allows me to quickly define validation rules and check my data objects against them. I know there is this another tool called FluentValidation but... I'm not a ...
1
vote
2answers
162 views

C# - exercise - object validation - reflection - generics - follow-up

Here's a C# class as an example for object validation. For this purpose I decided to use .NET reflection and tried to use generics, probably not in the correct way, that's why I'm writing this post. I ...
2
votes
2answers
471 views

Two methods to prompt the user to enter the width and length of a rectangle

I have two similar methods for setting dimensions of a rectangle. At first, I had them combined into one longer method that set width and length. I read about keeping code modular that performs one ...
2
votes
3answers
2k views

C# - exercise - object validation - reflection - generics

Just published (GitHub) a C# example for object Validation, for this purpose I decided to use the .NET Reflection and tried to use Generics. I would really like to improve coding, can you please give ...
3
votes
2answers
315 views

PHP class to send CRM records to Five9 API

I am experimenting with the Five9 API and setup 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 ...
3
votes
1answer
1k views

Asking the user to select a test subject and difficulty level

I'm currently in the early stages of a Python project, and the program (so far) asks the user what test they would like to take and what difficulty they would like it to be, and I'd like to know if ...
6
votes
2answers
512 views

Validate a password mostly to NIST-2017 standards

I have an application that needs to validate user passwords to a very reasonable custom validator, which is heavily based on NIST-2017 requirements. The validator intends to satisfy the following ...
1
vote
0answers
49 views

Approach for validation in domain layer

I was struggling for some time with proper implementation of domain validation in the context of domain entity and it's properties. By the time validation comes down to check if property value matches ...
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 ...
1
vote
1answer
2k views

Check that a data file contains the expected number of rows and columns of integers

This is a class I wrote check to check the format of .dat files. My code makes sure that the content of the files satisfies the conditions. A file can be deemed invalid if: The file can't be found. ...
2
votes
1answer
65 views

Validating input in a React app

I was writing some validation logic for a React-native app and thought I had so many bools flying around in my code! Is there any way to reduce redundancy in this code or is this the best that can be ...
7
votes
2answers
626 views

Validation for a CQS system that throws an exception

I've been reading that exceptions should only be for something "exceptional" and not used to control the flow of a program. However, with a CQS implementation, this seems impossible unless I start ...
2
votes
1answer
117 views

Validating and saving a user profile, using fat model vs. view code

I heard that fat models are good idea and I should avoid operations on database in my views so I do something like this below. Can you tell me if it's good idea and which version is better? Please ...
4
votes
3answers
135 views

C date information program

Inspired by a section from K&R C (exercises 5-8 and 5-9), I decided to write a program that would take a date numerous numeric forms, all based around DD/MM/YYYY, and from the given date determine ...
3
votes
1answer
2k views

Validation of integer inputs from a BufferedReader

At my school, we are using the BufferedReader for keyboard input for our console apps and I don't want to have to write ways to validate input for every project so I am writing a class to validate ...
1
vote
1answer
67 views

Submit form additions or changes using AJAX, and display result

I am submitting my form using ajax. Here is the actual code: ...
0
votes
3answers
1k views

Testing whether a string contains valid JSON by calling json_decode()

I had a code review and got told by the senior programmer that it was very bad programming practice to use the json_decode() function of php to determine if a string was not in JSON format. My ...
-1
votes
2answers
109 views

PHP Regex expression to validate a name input

As part of my validation I have the following regex expression: ...
1
vote
0answers
116 views

Validating data

Some time back I asked for some code to be reviewed and I was advised to pull the data validation into its own class. On a new class I decided to follow this advice. Before refactoring my code ...
1
vote
2answers
123 views

PHP form simple validation

I'm quite new to php (learned and only used C# for web pages so far) and wanted to know if this is the correct approach for validating a form. This is my userform.php code: ...
2
votes
2answers
395 views

Validating the difference in days between two dates

I have some code that is used for validating a condition based on dates, which is always a bit tricky. Here is the code: ...
6
votes
3answers
731 views

Insertion sort with high OOP and error processing

The input file contains data of one of two types: integers or strings. Data recorded in the column (each line of the file is a new element). Strings can contain any non-whitespace characters. The ...
9
votes
3answers
198 views

Check Accounting Journal for Errors

I wrote this sub in Excel VBA. I am a novice, but I was able to get my code to work how I wanted it to. Unfortunately, I can see there is a lot of repetition, but it is too complex for me to ...
1
vote
2answers
103 views

Validation before sending mail in PHP

In my initial problem posted on SO, whenever anyone accessed the Mail.php on the server, it used to send an empty email to the <...
5
votes
1answer
276 views

Validation for a user form using jQuery

I have a really bad habit at the moment with writing global specific functions to handle data and feel like I could reduce my work load by stop copying the same. Basically I have a registration form ...
6
votes
1answer
3k views

Validating a list of dictionaries of names and tags

I created a Python function to check the types from a list and also check the keys inside an dictionary within that list. I have the following data: ...
2
votes
1answer
2k views

Asking user input until a valid datetime is given (bloated try-except blocks)

Originally asked this on SO but was redirected here. I have a script that's asking the user to input a lot of dates, mostly in functions similar to the one below. These need to account for invalid ...