validation

Mongoose Model Custom Error Message for Enums

这一生的挚爱 提交于 2020-08-27 05:43:17
问题 I would like to customize the validation messages that my Mongoose Models produce. I tend to NOT put my validations (e.g. required) on the schema object directly because there is no freedom to have custom error messages. e.g. sourceAccountId: { type: Schema.ObjectId, require: true, ref: 'Account' } instead I do the following. sourceAccountId: { type: Schema.ObjectId, ref: 'Account' } ConnectionRequestSchema.path('sourceAccountId').required(true, 'Source Account is required.'); I have been

Mongoose Model Custom Error Message for Enums

末鹿安然 提交于 2020-08-27 05:42:08
问题 I would like to customize the validation messages that my Mongoose Models produce. I tend to NOT put my validations (e.g. required) on the schema object directly because there is no freedom to have custom error messages. e.g. sourceAccountId: { type: Schema.ObjectId, require: true, ref: 'Account' } instead I do the following. sourceAccountId: { type: Schema.ObjectId, ref: 'Account' } ConnectionRequestSchema.path('sourceAccountId').required(true, 'Source Account is required.'); I have been

Why do we no longer need to manually validate models in higher versions of ASP.NET Core?

。_饼干妹妹 提交于 2020-08-26 07:41:47
问题 All my models are automatically validated before hitting the endpoint, and return appropriate errors if some form of validation has failed. I remember back in ASP.NET Core 2.2 we needed to manually call ModelState.IsValid to make sure an object has passed validation checks, but with the latest ASP.NET Core 3.0, this doesn't seem to be the case, and nowhere am I including/configuring any services explicitly for this behavior to exist. Could someone shine some light on the matter, and perhaps

Why do we no longer need to manually validate models in higher versions of ASP.NET Core?

爷,独闯天下 提交于 2020-08-26 07:41:42
问题 All my models are automatically validated before hitting the endpoint, and return appropriate errors if some form of validation has failed. I remember back in ASP.NET Core 2.2 we needed to manually call ModelState.IsValid to make sure an object has passed validation checks, but with the latest ASP.NET Core 3.0, this doesn't seem to be the case, and nowhere am I including/configuring any services explicitly for this behavior to exist. Could someone shine some light on the matter, and perhaps

How to conditionally require form inputs in angular 4?

只谈情不闲聊 提交于 2020-08-24 05:12:32
问题 I am using template driven forms for adding the task, and there are 2 input fields of type number for estimated mins to complete task, one field is for estimated number of hrs and another is for estimated minutes to complete the task since the task estimate can be done either in hours like 1hrs , or in hours and minutes like 1Hrs 30Mins , so i want to set attribute required to inputs conditionally. So one of the 2 inputs must be set or form validation error will occur if both inputs are empty

How to conditionally require form inputs in angular 4?

Deadly 提交于 2020-08-24 05:09:52
问题 I am using template driven forms for adding the task, and there are 2 input fields of type number for estimated mins to complete task, one field is for estimated number of hrs and another is for estimated minutes to complete the task since the task estimate can be done either in hours like 1hrs , or in hours and minutes like 1Hrs 30Mins , so i want to set attribute required to inputs conditionally. So one of the 2 inputs must be set or form validation error will occur if both inputs are empty

How to conditionally require form inputs in angular 4?

我是研究僧i 提交于 2020-08-24 05:08:19
问题 I am using template driven forms for adding the task, and there are 2 input fields of type number for estimated mins to complete task, one field is for estimated number of hrs and another is for estimated minutes to complete the task since the task estimate can be done either in hours like 1hrs , or in hours and minutes like 1Hrs 30Mins , so i want to set attribute required to inputs conditionally. So one of the 2 inputs must be set or form validation error will occur if both inputs are empty

@NotNull : validation custom message not displaying

十年热恋 提交于 2020-08-24 03:33:23
问题 I am using spring data JPA for creating application. In that I am trying to implement server side validation using annotation. I added @NotNull annotation on filed with custom message. I also added @valid with @RequestBody But problem is that when I am passing nAccountId as null I am not getting custom message i.e. Account id can not be null I am getting "message": "Validation failed for object='accountMaintenanceSave'. Error count: 1", . Can any one please tell me why I am not getting custom

@NotNull : validation custom message not displaying

时光毁灭记忆、已成空白 提交于 2020-08-24 03:31:48
问题 I am using spring data JPA for creating application. In that I am trying to implement server side validation using annotation. I added @NotNull annotation on filed with custom message. I also added @valid with @RequestBody But problem is that when I am passing nAccountId as null I am not getting custom message i.e. Account id can not be null I am getting "message": "Validation failed for object='accountMaintenanceSave'. Error count: 1", . Can any one please tell me why I am not getting custom

Why is IValidatableObject.Validate only called if property validation passes?

孤者浪人 提交于 2020-08-22 09:21:07
问题 In my model, it seems that Validate() is only called AFTER both properties pass validation. public class MyModel : IValidatableObject { [Required] public string Name { get; set;} [Required] public string Nicknames {get; set;} public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) { if(Nicknames != null && Nicknames.Split(Environment.NewLine.ToCharArray()).Count() < 2) return yield result new ValidationResult("Enter at least two nicknames, new [] { "Nicknames" }); }