validation

I got a validation pipe's error when am passing email and password in the body of the postman

守給你的承諾、 提交于 2021-01-29 10:19:44
问题 Here is the screenshot of error: Here is the code of DTO: import {IsString, IsInt,IsEmail,IsNotEmpty, IsNumberString, IsIn} from 'class-validator' export class logindto{ @IsEmail() username:String @IsNotEmpty() password:String } Here is the code of controller: @Post('login') log(@Body('username')username:logindto,@Body('password')password:logindto):any{ return this.crudservice.loginsys(username,password) } Here is the code of services: export class CrudService { constructor(@InjectModel(

I am getting this error. Method Illuminate\Validation\Validator::validateReqiured does not exist

隐身守侯 提交于 2021-01-29 10:01:13
问题 I am getting this error for validation of form. Method Illuminate\Validation\Validator::validateReqiured does not exist. <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Event; use Illuminate\Support\Facades\Validator; use Illuminate\Validation\ValidationRequired; class EventController extends Controller { protected $events; public function __construct() { $this->property = new Event(); } /* get all data */ public function getEvents() { $events =Event::latest()-

Excel Dependent Dropdown List - Multiple Rows

荒凉一梦 提交于 2021-01-29 09:58:10
问题 I am trying to create a dependent drop-down list for multiple rows in excel. Essentially, what needs to happen is that the user can select a value for cell A1 and this value will determine the value that they can select in cell B2. However, I need this to be done for multiple rows - the trouble I run into is that if I just copy the data validation down column B, then in all other rows, it references cell A1, not cell A(x). Any ideas? 回答1: You can do this with a combination of named ranges ,

ControllerAdvice isn't picking IllegalArgumentException thrown by an incorrect UUID value passed as @RequestParam

こ雲淡風輕ζ 提交于 2021-01-29 07:33:22
问题 I have the following controller: @Slf4j @RestController @RequestMapping("/v1") @Validated public class HighlightController { // ... @GetMapping("/highlights") public ResponseEntity<List<Highlight>> getHighlights( @RequestParam(required = false) UUID impersonateUserId ) { // ... Then I have the following controller exception handler: @Slf4j @ControllerAdvice public class GlobalExceptionHandler { //... @ExceptionHandler(value = IllegalArgumentException.class) public ResponseEntity<Object>

Spring not returning default validation error responses

≯℡__Kan透↙ 提交于 2021-01-29 07:11:44
问题 I'm trying to get the default Spring 400 constrain violation errors working. I'm expecting this: { .... "status": 400, "error": "Bad Request", "errors": [ { .... "defaultMessage": "must not be null", .... } ], "message": "Validation failed for object='notNullRequest'. Error count: 1", .... } But I get: { "timestamp": "2020-07-31T08:30:06.992+00:00", "status": 400, "error": "Bad Request", "message": "", "path": "/v0.1/checkouts/1" } My POM: <project xmlns="http://maven.apache.org/POM/4.0.0"

Regular Expression Repeating Pattern delimited by comma

*爱你&永不变心* 提交于 2021-01-29 04:31:48
问题 I have a regular expression of the following in Javascript: /\w{1,}\s*\w{1,}/ This checks if a string has atleast two words greater than 1 character each. Ex- asd fgh - Valid a b d dfd - Valid xscxs - Invalid I now have a new requirement that I have tried to implement, but cannot get right. New requirement: Be able to have a comma separated list of the same type of input as before. Cannot end with a comma. Each item must be valid per the rules above. If there are no comma then also its valid.

一文教你实现 SpringBoot 中的自定义 Validator 和错误信息国际化配置

若如初见. 提交于 2021-01-29 04:31:28
一文教你实现 SpringBoot 中的自定义 Validator 和错误信息国际化配置 码农唐磊 程序猿石头 本文通过示例说明,在 Springboot 中如何自定义 Validator,以及如何实现国际化的错误信息返回。注意,本文代码千万别直接照抄,有可能会出大事情的。先留个悬念,读者朋友们能从中看出有什么问题吗? 项目初始化入 直接从 springboot 官网中下载模板,直接通过示例中的 GreetingController 添加实现逻辑。 @RestController public class GreetingController { private static final String template = "Hello, %s!"; private final AtomicLong counter = new AtomicLong(); @RequestMapping("/greeting") public Response<Greeting> greeting(@RequestParam(value = "name", defaultValue = "World") String name) { if (!"tangleithu".equals(name)) { throw new BadRequestException("user.notFound"); }

My form is not populating when there is some validation error in the input data. Laravel Collective

我与影子孤独终老i 提交于 2021-01-29 03:33:49
问题 Hope yo are all doing great. I am using Laravel 5.3 and a package LaravelCollective for form-model binding. I have subjects array that I want to validate and then store in database if there is no error in the input data. The following snippets show the partial view of form, other views, rules for validations and controller code. UserProfile.blade.php <!-- Panel that Adds the Subject - START --> <div class="col-md-12"> <div class="panel panel-default" id="add_Subject_panel"> <div class="panel

InvalidArgumentException in Carbon::createFromDate()->age

流过昼夜 提交于 2021-01-29 02:41:52
问题 Hello i'm writing a custom validation for input data in my laravel project. I'm using Carbon::createFromDate()->age in order to get user age and check whether he's 16 or more. I reckon i'm not doing it properly because i get InvalidArgumentException with such errors: The separation symbol could not be found The separation symbol could not be found A two digit minute could not be found Unexpected data found. Trailing data $rok is a year(1996 eg.) $miesiac is a month and $dzien is a Day. Pesel

Usage of @Valid vs @Validated in Spring

巧了我就是萌 提交于 2021-01-29 02:28:52
问题 Thanks to this question, I think I understand how validation is working. As for JPA, here we have a specification called JSR-303 explaining how Bean Validation should work and then we are using implementations like the commonly used Hibernate Validator or Apache BVal also. I am struggling about using @Valid in some part of my code. I am not using @Validated because I do not need group validation. You can find an example of a demo project here In PropertyExample class, you can see I marked my