I want to validate / sanitize the input for my criteria objects for a readonlylistbase object I have.
I created a validate routine in the readonlylistbase and the fetch's call the validate routine.
Private Sub ValidateCriteria(ByVal criteria As String) If criteria.Trim <> String.Empty OrElse Not Regex.IsMatch(criteria, "[0-9a-zA-Z-\s]{1,30}") Then Throw New Csla.Validation.ValidationException("Invalid search criteria") End If End SubIf it fails I throw a CSLA.Validation.ValidationException and let the caller handle it.
Catch ex As Exception If ex.GetBaseException.GetType.ToString = "Csla.Validation.ValidationException" Then' do something...
Else
'some other exception ''' TODO Add code for this.... End IfI believe this is the way to go to ensure if client validation fails or is subverted no matter where it is (web, forms,etc) then my object will stop it.
I am looking for feedback on if this is a good way to solve this....
Thanks,
Kevin
Copyright (c) Marimer LLC