Example #1
0
        internal void Validate()
        {
            var format = TextBoxValidationExtensions.GetFormat(_textBox);

            var expectNonEmpty = (format & ValidTextBoxFormats.NonEmpty) != 0;
            var isEmpty        = string.IsNullOrWhiteSpace(_textBox.Text);

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

            var expectNumber = (format & ValidTextBoxFormats.Numeric) != 0;

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

            MarkValid();
        }
Example #2
0
        protected virtual void MarkInvalid()
        {
            var brush = TextBoxValidationExtensions.GetInvalidBrush(_textBox);

            _textBox.Background = brush;
        }