Issue with Open Access ORM and IDataErrorInfo

Thread is closed for posting
3 posts, 0 answers
  1. Lorenzo
    Lorenzo avatar
    5 posts
    Member since:
    Nov 2012

    Posted 19 Nov 2013 Link to this post


    I found a problem using an example of the Open Access ORM documentation. (

    The implementation of the ValidateProperty method in this example has a problem. I tested it on a project by myself and found that if only one property of a business object is checked in this method and the validation of this field fails, all other properties of the object will have the same error message because '_error' field is shared by all of them. You have to initialize the error argument in the ValidateProperty method to empty before you check the properties.

    Partial Public Class Category
        Private Sub ValidateProperty(ByVal propertyName As String, ByRef [error] As String)
               [error] = "" 'If you don't do this initialization, all the fields that follow the
                                   'last that fails validation
                                   'will share the same error message
            Select Case propertyName
                Case "CategoryID"
                    If CategoryID < 0 Then
                        [error] = "The identification number of the category cannot be negative"
                    End If
                Case "CategoryName"
                    If String.IsNullOrWhiteSpace(CategoryName) Then
                        [error] = "You need to provide a name for the category"
                    End If
            End Select
        End Sub
    End Class

    I could be wrong, but that is the way I sort it out.

    Thank you,
  2. Doroteya
    Doroteya avatar
    498 posts

    Posted 22 Nov 2013 Link to this post

    Hello Lorenzo,

    Thank you for bringing this issue to our attention.

    Indeed, setting [error] to String.Empty at the beginning of the ValidateProperty() method is required in order to provide a different error message for each property, each time an instance of the class is validated. Your remark will be reflected in our documentation with its upcoming update.

    Note, however, that the implementation of the ValidateProperty() method can vary depending on the requirements and the complexity of the specific scenario IDataErrorInfo participates in.

    If you encounter any other issues in our documentation or if you have technical questions, do not hesitate to get back to us.

    OpenAccess ORM Q3 2013 simplifies your model operations even further providing you with greater flexibility. Check out the list of new features shipped with our latest release!
  3. Lorenzo
    Lorenzo avatar
    5 posts
    Member since:
    Nov 2012

    Posted 23 Nov 2013 Link to this post

    Hello Doroteya,

    thank you for your answer. I came across to this issue because I wanted to use the ErrorProvider component and every time there were a validation error on a field, all the other fields would show the error icon.

    Lorenzo Martin Edreira
Back to Top