xval

xVal, DataAnnotations on the entire class

二次信任 提交于 2020-01-03 17:26:29
问题 I have a complete validation on an obeject and am trying to figure out the best way to handle it. Given the following class: public class LetterResponse { public Guid Id {get;set;} public bool SendBlankCart {get;set;} public string ToName {get;set;} public string ToAddress {get;set;} } I want to use a dataannotation and xval in order to validate the class before I persist it, but I have complex validation that requires more than one property. Pseudo: if SendBlankCart { - no validation on

xVal, DataAnnotations on the entire class

百般思念 提交于 2020-01-03 17:25:39
问题 I have a complete validation on an obeject and am trying to figure out the best way to handle it. Given the following class: public class LetterResponse { public Guid Id {get;set;} public bool SendBlankCart {get;set;} public string ToName {get;set;} public string ToAddress {get;set;} } I want to use a dataannotation and xval in order to validate the class before I persist it, but I have complex validation that requires more than one property. Pseudo: if SendBlankCart { - no validation on

xVal client-side validation not working

廉价感情. 提交于 2019-12-25 06:54:52
问题 I downloaded the xVal sample project from Steve Sanderson’s blog, run it, and the sever side validation it's working (after i click submit), but the client side doesn't; although i looked at the source and saw the generated javascript <script type="text/javascript">xVal.AttachValidator("booking", {"Fields":[{"FieldName":"ClientName","FieldRules":[{"RuleName":"Required","RuleParameters":{}},{"RuleName":"StringLength","RuleParameters":{"MaxLength":"3"}}]},{"FieldName":"NumberOfGuests",

xVal and ASP.Net MVC 2 AddModelStateErrors Problem

限于喜欢 提交于 2019-12-21 09:36:46
问题 I have an application that I've been using xVal successfully on for quite some time. It was recently updated to MVC 2. I use the standard DataAnnotations attributes on my domain models, which also implement a "Validate()" method that calls the DataAnnotationsValidationRunner. If there are any errors, that method throws a RulesException. In my controllers, I use the very typical catch for RulesException catch (RulesException e) { e.AddModelStateErrors(ModelState, "err"); } All typical stuff,

xval vs MVC 3.0 validations

守給你的承諾、 提交于 2019-12-11 07:44:08
问题 I was wondering if anyone has any opinions regarding the usage of xVal or MVC 3.0 model validation? I originally started using xVal because of its ability to validate both client and server side but the project appears to be dead (perhaps dormant is a better word) and it appears that validation in MVC 2.0 and 3.0 has greatly improved. What are the advantages, if any, to using xval over MVC3.0 validation and vice versa? Any advice is appreciated, Thank you JP 回答1: I think there is no advantage

Using xval with fields containing periods

本秂侑毒 提交于 2019-12-11 06:49:07
问题 I have been using xVal with success for a while but this evening ran into an issue where a field containing a period would not be validated (client or server-side). I am using ASP.NET MVC2 and need to use the period syntax in cases where I am model binding to a list. In the below example I am using a textbox for the sake of simplicity: xVal.AttachValidator(null, { "Fields": [{ "FieldName": "entry[622592].Value", "FieldRules": [{ "RuleName": "Required", "RuleParameters": {}}]}] }, {}) <input

How can I use a custom ValidationAttribute to ensure two properties match?

邮差的信 提交于 2019-12-11 00:14:04
问题 We're using xVal and the standard DataAnnotationsValidationRunner described here to collect validation errors from our domain objects and view models in ASP.NET MVC. I'd like to have a way to have that validation runner identify when two properties don't match through the use of custom DataAnnotations. Right now I'm forced into doing it outside of the runner, this way: if (!(model.FieldOne == model.FieldTwo)) errors.Add(new ErrorInfo("FieldTwo", "FieldOne must match FieldTwo", model.FieldTwo)

ASP.NET MVC ValidateInput(false) stops working with xVal and [RegularExpression] DataAnnotation

白昼怎懂夜的黑 提交于 2019-12-10 00:44:54
问题 I would like to intercept the "<" character in the form field by a regex validator. I will describe the problem in 3 steps: Step 1 : When I try to submit a form with a field containing the "<" character, I get the "Potentially dangerous request..." - as expected in ASP.NET. Step 2 : To avoid ASP.NET's RequestValidation, I decorate my Update method in the controller with "[ValidateInput(false)]". It works as expected - now I can post "<" character without error. Step 3 : I use xVal with

Auto generating metadata classes for Entity Framework

别说谁变了你拦得住时间么 提交于 2019-12-07 11:00:32
问题 I am considering using xVal for validation of Entity Framework classes in a MVC application. This involves writing metadata classes as explained in details by Graham O'Neale (http://goneale.com/2009/03/04/using-metadatatype-attribute-with-aspnet-mvc-xval-validation-framework). I am wondering if there's a way to auto generate such metadata classes using the metadata from the SQL database (for example: not null fields will have [Required] class attribute. 回答1: You could use Code Smith tool www

Auto generating metadata classes for Entity Framework

假装没事ソ 提交于 2019-12-05 13:40:23
I am considering using xVal for validation of Entity Framework classes in a MVC application. This involves writing metadata classes as explained in details by Graham O'Neale ( http://goneale.com/2009/03/04/using-metadatatype-attribute-with-aspnet-mvc-xval-validation-framework ). I am wondering if there's a way to auto generate such metadata classes using the metadata from the SQL database (for example: not null fields will have [Required] class attribute. You could use Code Smith tool www.codesmithtools.com (there is a free version if I remember correctly) I wrote an application that will read