Switching ValidationStates

2 posts, 0 answers
  1. Vitalii
    Vitalii avatar
    104 posts
    Member since:
    Jul 2013

    Posted 03 Oct 2013 Link to this post

    So, i'm doing field check in the VM, and send message with status to the View. 
    However, when i'm having different Invalid messages, they are not having effect for the field message (probably due to optimization).

    Sample:
                        switch (_results.ZipStatus)
                        {
                            case 0: // Ok
                                ZipTextBox.ChangeValidationState(ValidationState.Valid, "Ok");
                                break;
                            case 1: // String is empty
                                ZipTextBox.ChangeValidationState(ValidationState.Invalid, "Cant be empty");
                                break;
                            case 2: // String.Count != 5
                                ZipTextBox.ChangeValidationState(ValidationState.Invalid, "Should be Zip"); 
                                break;
                        }

    If user enters nothing, it would be 1 case, and he would get "Cant be empty" message.
    Then, if he would enter 2 digits, it would be 2 case, but he would still see "Cant be empty" message.
    Then, if to enter 5 digits, it would be 0 case, he would see "Ok" message;
    Then, if to enter 2 digits again, it would be 2 case, and now user would see "Should be Zip" message.

    As mentioned before, i assume, it is caused by optimization (if still Invalid state, dont change message), but with this scenario, it is working wrong. I guess, workaround is just to set it to ValidationState.Validating before switching.
  2. Vitalii
    Vitalii avatar
    104 posts
    Member since:
    Jul 2013

    Posted 03 Oct 2013 Link to this post

    Yep, now its ok

                        ZipTextBox.ChangeValidationState(ValidationState.Validating, String.Empty);
                        switch (_results.ZipStatus)
                        {
                            case 0: // Ok
                                ZipTextBox.ChangeValidationState(ValidationState.Valid, "Ok");
                                break;
                            case 1: // String is empty
                                ZipTextBox.ChangeValidationState(ValidationState.Invalid, "Cant be empty");
                                break;
                            case 2: // String.Count != 5
                                ZipTextBox.ChangeValidationState(ValidationState.Invalid, "Should be Zip"); 
                                break;
                        }
  3. DevCraft banner
Back to Top