validation

ASP.NET Core [Require] non-nullable types

前提是你 提交于 2020-06-25 02:28:49
问题 Here, the question was posed how to validate non-nullable required types. The provided solution to make the field nullable like the following is not desirable in my case. [Required] public int? Data { get; set; } How can you change the behavior to instead make the following fail validation in the cases where the field is omitted from the request. [Required] public int Data { get; set; } I have tried a custom validator, but these do not have information about the raw value and only see the

How to use a pattern on an input[type=“number”]?

守給你的承諾、 提交于 2020-06-23 07:46:29
问题 I want the default value to be 0 and recolor the input if it's more than 0, using :valid . Am I doing something wrong? Is Google Chrome wrong? Or the HTML5 specification? I want to solve this without JS. :valid { background: green } <p>This should not be green, but it is:</p> <input max="100" min="0" pattern="^[1-9]\d*$" type="number" value="0" /> <p>Works perfectly, if the type is changed to text:</p> <input pattern="^[1-9]\d*$" type="text" value="0" /> 回答1: Citing MDN on the pattern

Angular2 Custom Form Validators losing access to `this` in class

青春壹個敷衍的年華 提交于 2020-06-22 13:30:11
问题 I'm building an Angular 2 application (2.0) and I've got a form that makes use of the ReactiveForms module. As such, I'm using validator functions on the input fields, including custom validators. This works fine. My issue is that I am also trying to use a custom AsyncValidator on a form field. It seems straight forward enough, but I can never reference properties inside the class from within the AsyncValidator method. The FormGroup and the FormControl properties for the form itself and the

Spring Boot - Validations stopped working after upgrade from 2.2.5 to 2.3.0

被刻印的时光 ゝ 提交于 2020-06-22 12:03:08
问题 I've migrated a Spring Boot project from 2.2.5 to 2.3.0 and after that, Validations stopped to work (they aren't invoked at all). I read in changelog documentation (https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3.0-M1-Release-Notes), that spring-boot-starter-validation now needs to be added manually as a dependency. So, I added it to my pom.xml: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</artifactId> </dependency> My

Need help creating an html page with an external JS file that validates this format AAA.111#2222_aa-1234

我们两清 提交于 2020-06-17 11:42:28
问题 This is my html page. Im trying to validate this format AAA.111#2222_aa-1234. Im not sure whats stopping the html file from accessing the JS file. OR if my regular expression in the JS file is even correct. <html lang = "en"> <head> <title>random</title> </head> <body> <form> <p>Please enter course information</p> <input type="text" name="userInput" id="userInput" maxlength="15"> <input type="button" value="validate" onclick="validationFunction()"> </body> </html> This is my external JS file.

Spring boot @Valid on requestBody in controller method not working

六眼飞鱼酱① 提交于 2020-06-17 09:32:29
问题 I am trying to validate a simple request body annotated by @Valid annotation in a @RestController annotated by @Validated. Validations are working correctly on primitive variable in request (on age in below example) but not working on pojo request body. @Valid annotation has no effect on request body Person class (i.e. controller accepting blank name and age under 18). Person class: import javax.validation.constraints.Min import javax.validation.constraints.NotBlank class Person ( @NotBlank

Spring boot @Valid on requestBody in controller method not working

孤街醉人 提交于 2020-06-17 09:32:16
问题 I am trying to validate a simple request body annotated by @Valid annotation in a @RestController annotated by @Validated. Validations are working correctly on primitive variable in request (on age in below example) but not working on pojo request body. @Valid annotation has no effect on request body Person class (i.e. controller accepting blank name and age under 18). Person class: import javax.validation.constraints.Min import javax.validation.constraints.NotBlank class Person ( @NotBlank

in Google Apps Script; using Regular Expression & Conditional formatting - to create a IPv4 address validator / checker

这一生的挚爱 提交于 2020-06-17 03:42:29
问题 in Google Apps Script; using Regular Expression & Conditional formatting - to create a IPv4 address validaton / checker 1. VALIDATING the input with regular expression : I try to make a script to get feedback of a validator, to check if the input an IP addresses is. regular expression pattern : cell ' ip!I12 ' named ' REGEXP_IP_pattern ' : ^((((25[0-5])|(2[0-4][0-9])|([01]?[0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|([01]?[0-9]{1,2}))) reg exp demo : https://regexr.com/54fon - works fine (in

Improve mongoose validation error handling

北城以北 提交于 2020-06-16 20:49:19
问题 I have the following schema with required validations: var mongoose = require("mongoose"); var validator = require("validator"); var userSchema = new mongoose.Schema( { email: { type: String, required: [true, "Email is a required field"], trim: true, lowercase: true, unique: true, validate(value) { if (!validator.isEmail(value)) { throw new Error("Please enter a valid E-mail!"); } }, }, password: { type: String, required: [true, "Password is a required field"], validate(value) { if (

Improve mongoose validation error handling

家住魔仙堡 提交于 2020-06-16 20:48:41
问题 I have the following schema with required validations: var mongoose = require("mongoose"); var validator = require("validator"); var userSchema = new mongoose.Schema( { email: { type: String, required: [true, "Email is a required field"], trim: true, lowercase: true, unique: true, validate(value) { if (!validator.isEmail(value)) { throw new Error("Please enter a valid E-mail!"); } }, }, password: { type: String, required: [true, "Password is a required field"], validate(value) { if (