May 12, 2010 at 12:29 PM
Edited May 12, 2010 at 12:33 PM
|
I want to use FV & DataAnnotations for Validation (both together). I am aware that removing the MetadataProvider line means MVC takes care of metadata vs. FV taking care of it while the line is present.
Meanwhile, i am still unable to get Validation for FV and DA (DataAnnotations) working together. I am able to get DA MetadataProvider working while FV Validation is working, however, as soon as i add a DA Validation reference to my test, FV Validation is
disabled and the DA Validation works only! Here is an example of a class structure where FV Validation si auto-dsabled/doesn't work:
<Validator(GetType(tProductValidator))>
Partial Public Class tProduct
End Class
<MetadataType(GetType(tProductValidatorX))> _
Partial Public Class tProduct
End Class
Public Class tProductValidatorX
<DisplayName("Product Name XX")>
<Required(ErrorMessage:="haha it works")>
Public Property ProductName As String
End Class
Public Class tProductValidator
Inherits AbstractValidator(Of tProduct)
... this is where FV rules reside...
End Class
Above, ONLY DA Validation works (FV Validation does not), on the ProductName Required test. Now, if you remove the <Required(ErrorMessage:="haha it works")> the FV Validation works, and the DA Validation does not! They just switch on/off
depending its like one switches the other off and they never work together. I have tried several different class setup structures.
It really would be a dream to get both of these working together, don't you think? Maybe i'm just over excited but your Framework combined with inherent DA attributes for simple stuff would be a validation dream.
|