Better way to check variable for null or empty string?

Since PHP is a dynamic language what's the best way of checking to see if a provided field is empty? I want to ensure that: null is considered an empty string a white space only string is...

Validating URL in Java

I wanted to know if there is any standard APIs in Java to validate a given URL? I want to check both if the URL string is right i.e. the given protocol is valid and then to check if a connection...

JavaScript file upload size validation

Is there any way to check file size before uploading it using JavaScript?

How to validate numeric values which may contain dots or commas?

I need a regular expression for validation two or one numbers then , or . and again two or one numbers. So, these are valid inputs: 11,11 11.11 1.1 1,1

How to disable schema validation in Hibernate for certain entities?

How do I disable schema validation in Hibernate for certain entities (not all)? Some of my entities are using SQL which lead to fail validation so I want to disable validation for them.

only allow English characters and numbers for text input

Live Demo: http://jsfiddle.net/thisizmonster/DveuB/ How can I change this so that the input only allows the characters A-Z, a-z, 0-9 while typing, without using a regular expression?

Right HTTP status code to wrong input

What is optimal HTTP response Code when not reporting 200 (everything OK) but error in input? Like, you submit some data to server, and it will response that your data is wrong using 500 looks...

How do i specify and validate an enum in rails?

I currently have a model Attend that will have a status column, and this status column will only have a few values for it. STATUS_OPTIONS = {:yes, :no, :maybe} I am not sure how i can validate...

Raise a validation error in a model's save method in Django

I'm not sure how to properly raise a validation error in a model's save method and send back a clear message to the user. Basically I want to know how each part of the "if" should end, the one...

Function to check if a string is a date

I am trying to write a function to determine if a string is a date/time using PHP. Basically a valid date/time would look like: 2012-06-14 01:46:28 Obviously though its completely dynamic any...

Validate Canadian Postal Code Regex

I have a script written in JavaScript to Validate Canadian Postal Codes using Regex, however it does not seem to be working. Here is the script: If statement: if (myform.zip.value == "" ||...

HTML5 Form Validation

I have two major problem regarding HTML5 form validation. 1- I use this code to change the validation message of inputs $$('INPUT').each(function(input) { input.oninvalid = function(event)...

javascript: prevent page from blocking ctrl+c / ctrl+v

Some form validators block CTRL+C/CTRL+V on some input fields. Is there a quick bookmarklet or something that could allow me to use my keyboard properly. Or, perhaps, browsers allow my to override...

Should I care about W3C validation?

I'm learning AngularJS and I found a simple code like this one: <!DOCTYPE html> <html> <head> <meta charset='utf-8'> <script...

Mongoose validation: required : false, validate : regex, issues with empty values

I get this message from Mongoose validation: 'Validator failed for path phone with value ``' That shouldn't happen since phone is not required. Here's my model schema: var user = new Schema( {...

JSDoc - how to check types for JavaScript

I am applying JSDoc annotations: /** * @param {number} millis * @param {function} callback * */ function sleep(millis, callback) { setTimeout(function() { callback(); }, millis); } Then...

Use ValidateSet with the contents loaded from a CSV file

I really like the way that ValidateSet works. It proposes the options as a list while you type your Cmdlet in the PowerShell ISE. I would like to know if it's possible to retrieve values from a...

What is a reliable isnumeric() function for python 3?

I am attempting to do what should be very simple and check to see if a value in an Entry field is a valid and real number. The str.isnumeric() method does not account for "-" negative numbers, or...

WPF StringFormat to allow only positive numbers

I only want to allow positive numbers as user input in my TextBox. If I input -10 and use <TextBox Text="{Binding Width, StringFormat={}{0:0.00;0.00}}" /> then it always displays positive...

Java validating postal code

I'm trying to write a program that will validate a Canadian postal code with the format A1A1A1 or A1A 1A1. I'm having problems getting my code to recognize the white space in the second...

Get all validation errors from Angular 2 FormGroup

Given this code: this.form = this.formBuilder.group({ email: ['', [Validators.required, EmailValidator.isValid]], hasAcceptedTerms: [false, Validators.pattern('true')] }); How can I get all...

GST number validatoin in jquery

I want to do GST validation in javascript or jquery Its limited to india only. the structure of GST in India is as follows GST Number will be of 15 digits having below validations: a. First two...

Does Pymongo have validation rules built in?

I am trying to validate an inserted document against a schema, and was trying to find a way to validate the inserted document. There are libraries like MongoEngine that say they do the work, but...

Validation of ASP.NET Core options during startup

Core2 has a hook for validating options read from appsettings.json: services.PostConfigure<MyConfig>(options => { // do some validation // maybe throw exception if appsettings.json has invalid...

Laravel: Validating a number greater than zero is failing

I gotta validate a price field which needs to be greater than zero (0.01 is valid) so I have the following validation: $request->validate([ 'product_price' => 'required|numeric|gt:0', ...

Joi validation - how to require or optional field based on another key exists in array?

I have this Joi schema: let schema = {}; let stations = { contact: { first_name: Joi.string().min(2).max(10).regex(Regex.alphabeta, 'alphabeta').allow("").error(JoiCustomErrors), ...

Column not found: 1054 Unknown column 'id' in 'where clause' (SQL: select count(*) as aggregate from `item` where `barcode` = A002 and `id` <> 12)

I try to update my table Item but I use unique validation in my controller, I have set the primary key = 'item_id' in my model but I keep get this error said unknown column id even though I have...

ReactJS and Typescript : refers to a value, but is being used as a type here (TS2749)

I'm coding a ReactJS class with Typescript and Material-ui, in a .tsx file. In one of my custom components, I want to create a reference to one of the components that I use in my custom...

Formik validation schema Yup , when is "answer" or "another answer"

Basicaly all I want to do is say is if region = "Europe" or "other" then the field is required, did go through the formik documentation but not finding...

Flutter form is showing error for all the fields all at once. How can I make it to show the validation message of one field after the other?

below is my code. i have 6 fields. all of them are showing error all at once. even after i submit the form. once it gets cleared. it would show the validation message as field cannot be empty...