Validation Rules Question

Validation Rules Question

Old forum URL: forums.lhotka.net/forums/t/2775.aspx


eslater posted on Wednesday, April 25, 2007

I am looking at what is involved in moving to CSLA 2.x from 1.5 and have a couple of questions about the new Validation Rules:

1 - How would you create a rule for a required field that is not a string?  Most of my FK fields are required and are guids

2 - Do you require rules for Decimal.MinValue/Decimal.Max value?

On a more general note is a realistic amount of time to upgrade a class and form to 2.x?

Thanks for any help,
Elliot

RockfordLhotka replied on Wednesday, April 25, 2007

In general terms, today in 1.5 you have something like

  BrokenRules.Assert(..., <conditional>)

And in 2.1 this translates to a rule method like:

  Private Shared Function MyRule(...) As Boolean
    If Not <conditional> Then
      e.Description = "You broke my rule"
      Return False

    Else
      Return True
    End If
  End Function

Today you already have conditionals that check your Guid values and your Decimal values. All you need to do is move the <conditional> clause from the Assert() method into a rule method.

Copyright (c) Marimer LLC