Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

WebDucer Value Validators

Library with common value validators to be used in UI application (e.g. ASP.Net Core, Xamarin, UWP, WPF). The library is based on the ideas from the following book:


Service Last Develop Master
AppVeyor last Build status last Build status develop Build status master
SonarCube coverage SonarQube Coverage SonarQube Coverage
SonarCube technical debt SonarQube Technical Debt SonarQube Technical Debt
SonarCube Quality Gate SonarQube Quality Gate SonarQube Quality Gate
Nuget NuGet NuGet Pre Release NuGet


  • IValidationRule<T>: Generic interface for the rules
  • IValidatable: Interface to handle validation
  • IValidatableValue<T>: Generic interface for a validatable value
  • IValidatableValue: Non geniric interface for validatable value (mostly implemented explizit)

Validation Rules

  • ContainsValidationRule - Check, if the value is in the given collection (with possibility to inverse the result)
  • EmailValidationrule - Check, if the value is a valid email address
  • EqualValuesValidationRule<T> - Compare two values for equality
  • NullValidationRule - Check, if the value is null
  • PhoneNumberValidationRule - Check, if the value is valid phone number (with allowed separators -, (), .)
  • RangeValidationRule<T> / PrimitiveRangeValidationRule - Compare the value to a given min and max values
  • RegexValidationRule - Check, if the value match the given regular expression
  • RequiredValidationRule - Check, if the string value is set (with a flag, for white spaces treaded as valid values)
  • StringLengthValidationRule - Check the max or min length of a string
  • GreaterThanValidationRule - Check, if the value is greater (or equal) to a given value
  • SmallerThanValidationRule - Check, if the value is smaller (or equal) to a given value
  • RevalidateOtherValueValidationRule - Trigger the validation of another validatable value


Initialize your validatable values in your view model.

MyValidatableValue = new ValidatableValue<string>
    ValidationRules = new IValidationRule<string>[]
        new ContainsValidationRule<string>(
            errorMessage: "Value not allowed",
            checkCollection: new[] {"test", "example", "fake"},
            nullOrEmptyIsValid: true),
        new StringLengthValidationRule(
            errorMessage: "The value should have at least 2 characters
            length: 2,
            checkMaxLength: false),
        new StringLengthValidationRule(
            errorMessage: "The value should have at maximum 16 charachters",
            length: 16),
        new RequiredValidationRule(errorMessage: "Value is required")

Bind the value in your XAML code.

<Label Text="My value:" />
<Entry Text="{Binding MyValidatableValue.Value}"
       BackgroundColor="{Binding MyValidatableValue.IsValid, Converter={StaticResource ValidationColorConverter}}"/>
<Label Text="{Binding MyValidatableValue.FirstError}"
       Style="{StaticResource ErrorMessage}" />


Android screenshot

iOS screenshot

UWP screenshot

WPF screenshot

macOS screenshot