Validation block

J

jack

Im a new bee in validation

Im just in the design phase of the project and not thinking about
having a saperate validaion block.

Just browsed through validaion block of enterprise library which is
one of the options which ill use..

I would be glad if some one help me with any of the resources or idea
of how to handle validaitons in project..Like creating saperate
component for validation.
 
N

Nick Chan

my custom textbox has something like this

txt.Required = true
txt.DataType = String,Integer,Money,Date, RegExp etc...
txt.RegExp = "#@$@"
txt.AutoTrim = true
txt.MinLength
txt.MaxLenght
txt.EnableValidation
txt.MinValue
txt.MaxValue
txt.ErrorBackgroundColor
txt.ErrorMessage
txt.FriendlyName
txt.AutoUpCase

i do my own custom dropdownlist, custom this custom that

all of controls, i implement IValidator

Partial Class Controls_UCTextbox

Inherits CBaseControl

Implements IValidator

Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
MyBase.OnInit(e)
Page.Validators.Add(Me)
End Sub

Protected Overrides Sub OnUnload(ByVal e As System.EventArgs)
If Not IsNothing(Page) Then
Page.Validators.Remove(Me)
End If
MyBase.OnUnload(e)
End Sub

etc....


validationsummary will get messages from ErrorMessage (IValidator
method declaration). I learn this from codeproject, and enhance it
myself

I prefer this way, easy to maintain, and boosts employee's morale.
 
B

Brian K. Williams

If you are going to use Validation Block, this is how I used it.



I store regular expression validations on the database extended properties
description for each field. The first line is always a description; followed
by carriage return, regular expression, carriage return, and regular
expression error message. I then used CodeSmith and wrote a template to
write my Data Transfer Object with Validation Block attributes for
StringLengthValidator, Allow Nulls, Comment Description, Regular
Expressions, etc. using the values in the database extended properties and
DB Schema.




You can also use Policy Injection with Validation Block for additional
validations.



Regards,

Brian K. Williams
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top