Typely
GitHub
  • Overview
    • πŸ‘Welcome!
  • Validations
    • πŸ“Common
    • πŸ”’Number
    • βš–οΈComparable
    • ✏️String
  • Customize errors
    • 🌎Localization
    • πŸ”Sensitive data
  • General
    • 🧩Class VS Struct
    • πŸ–ΌοΈSupported frameworks
    • πŸš€Benchmarks
    • ⚠️Limitations
  • Design decisions
    • πŸ”„Conversions
    • ℹ️Use of interfaces
    • πŸ€Έβ€β™‚οΈUnderlying type comparison
    • πŸ’‚Validations
Powered by GitBook
On this page
  • LessThan Validator
  • LessThanOrEqual Validator
  • GreaterThan Validator
  • GreaterThanOrEqual Validator
Edit on GitHub
  1. Validations

Comparable

For types that implement IComparable<T>

LessThan Validator

Ensures that the value is less than the specified value.

Example:

builder.OfInt().For("Age").LessThan(120);

Example error: 'Age' must be less than 120.

String format args:

  • Name: Name of the type being validated

  • Value: Current value of the property

  • ComparisonValue: Value compared to.

LessThanOrEqual Validator

Ensures that the value is less than or equal to the specified value.

Example:

builder.OfInt().For("Age").LessThanOrEqualTo(120);

Example error: 'Age' must be less than or equal to 120.

String format args:

  • Name: Name of the type being validated

  • Value: Current value of the property

  • ComparisonValue: Value compared to.

GreaterThan Validator

Ensures that the value is greater than the specified value.

Example:

builder.OfInt().For("Age").GreaterThan(120);

Example error: 'Age' must be greater than 120.

String format args:

  • Name: Name of the type being validated

  • Value: Current value of the property

  • ComparisonValue: Value compared to.

GreaterThanOrEqual Validator

Ensures that the value is greater than or equal to the specified value.

Example:

builder.OfInt().For("Age").GreaterThanOrEqualTo(120);

Example error: 'Age' must be greater than or equal to 120.

String format args:

  • Name: Name of the type being validated

  • Value: Current value of the property

  • ComparisonValue: Value compared to.

PreviousNumberNextString

Last updated 2 years ago

βš–οΈ