Imports Microsoft.Practices.EnterpriseLibrary.Common.Configuration
Imports Microsoft.Practices.EnterpriseLibrary.Validation
Imports Microsoft.Practices.EnterpriseLibrary.Validation.Validators
Public Class Customer
Private _firstName As String
Private _lastName As String
Private _dateOfBirth As DateTime
Private _email As String
Private _address As Address
Private _rewardPoints As Integer
<StringLengthValidator(1, 50, Ruleset:="RuleSetA", _
MessageTemplate:="First Name must be between 1 and 50 characters")> _
Public Property FirstName() As String
Get
Return _firstName
End Get
Set(ByVal value As String)
_firstName = value
End Set
End Property
<StringLengthValidator(1, 50, Ruleset:="RuleSetA", _
MessageTemplate:="Last Name must be between 1 and 50 characters")> _
Public Property LastName() As String
Get
Return _lastName
End Get
Set(ByVal value As String)
_lastName = value
End Set
End Property
<RelativeDateTimeValidator(-120, DateTimeUnit.Year, -18, _
DateTimeUnit.Year, Ruleset:="RuleSetA", _
MessageTemplate:="Must be 18 years or older.")> _
Public Property DateOfBirth() As DateTime
Get
Return _dateOfBirth
End Get
Set(ByVal value As DateTime)
_dateOfBirth = value
End Set
End Property
<RegexValidator("\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", _
MessageTemplate:="Invalid e-mail address", _
Ruleset:="RuleSetA")> _
Public Property Email() As String
Get
Return _email
End Get
Set(ByVal value As String)
_email = value
End Set
End Property
<ObjectValidator("ValidAddress", Ruleset:="RuleSetA")> _
Public Property Address() As Address
Get
Return _address
End Get
Set(ByVal value As Address)
_address = value
End Set
End Property
<RangeValidator(0, RangeBoundaryType.Inclusive, 1000000, _
RangeBoundaryType.Inclusive, Ruleset:="RuleSetA", _
MessageTemplate:="Rewards points cannot exceed 1,000,000")> _
Public Property RewardPoints() As Integer
Get
Return _rewardPoints
End Get
Set(ByVal value As Integer)
_rewardPoints = value
End Set
End Property
End Class