/// <summary>
        /// Mark text box as text box with invalid entered value.
        /// </summary>
        protected virtual void MarkInvalid()
        {
            var brush = TextBoxValidationExtensions.GetInvalidBrush(_textBox);

            _textBox.Background = brush;
            TextBoxValidationExtensions.SetIsValid(_textBox, false);
        }
        internal void Validate()
        {
            var format = TextBoxValidationExtensions.GetFormat(_textBox);

            var expectNonEmpty = format.HasFlag(ValidTextBoxFormats.NonEmpty);
            var isEmpty        = String.IsNullOrWhiteSpace(_textBox.Text);

            if (expectNonEmpty && isEmpty)
            {
                MarkInvalid();
                return;
            }

            var expectNumber = format.HasFlag(ValidTextBoxFormats.Numeric);

            if (expectNumber &&
                !isEmpty &&
                !IsNumeric())
            {
                MarkInvalid();
                return;
            }

            var expectPhone = format.HasFlag(ValidTextBoxFormats.Phone);

            if (expectPhone)
            {
                if (!isEmpty)
                {
                    IEnumerable <string> phones = PhoneNumbersInputParser.Parse(_textBox.Text);

                    string convertedNumber = String.Empty;
                    bool   isValid         = phones.All(number => PhoneNumberConverter.ConvertToIsdn(number, ref convertedNumber));

                    if (isValid)
                    {
                        MarkValid();
                    }
                    else
                    {
                        MarkInvalid();
                    }
                }
                else
                {
                    MarkInvalid();
                }

                return;
            }

            MarkValid();
        }