annotations library

This library contains all available validation annotations.

To use, import package:validations/annotations.dart

It contains all of the below sub libraries:

  • annotations.basic
  • annotations.choice
  • annotations.collection
  • annotations.comparison
  • annotations.date
  • annotations.file
  • annotations.mixed
  • annotations.money
  • annotations.number
  • annotations.string

Classes

After
Checks whether the annotated date is after the specified date.
Alpha
Checks that the annotated string contains only alpha characters A-z.
Before
Checks whether the annotated date is before the specified date.
Blank
Checks that the annotated string is null or the length is not greater than 0.
CreditCardNumber
Checks that the annotated string passes the Luhn checksum test.
DecimalMax
Checks whether the annotated value is less than the specified maximum, when inclusive=false. Otherwise whether the value is less than or equal to the specified maximum. The parameter value is the string representation of the max value.
DecimalMin
Checks whether the annotated value is larger than the specified minimum, when inclusive=false. Otherwise whether the value is larger than or equal to the specified minimum. The parameter value is the string representation of the min value.
Digits
Checks whether the annotated value is a number having up to integer digits and fraction fractional digits.
DivisibleBy
Checks whether the annotated value is divisible by the specified value.
DurationMax
Checks that annotated Duration element is not greater than the one constructed from annotation parameters. Equality is allowed if inclusive flag is set to true.
DurationMin
Checks that annotated Duration element is not less than the one constructed from annotation parameters. Equality is allowed if inclusive flag is set to true.
Email
Checks whether the specified string is a valid email address.
EqualTo
Checks whether the annotated value is equal to another value.
FieldMatch
FutureOrPresent
Checks whether the annotated date is in the present or in the future
GenValidator
GreaterThan
Checks whether the annotated value is higher than the specified value.
GreaterThanOrEqual
Checks whether the annotated value is higher than or equal to the specified minimum.
Hexadecimal
Checks that the annotated string is a valid hexadecimal.
HexColor
Checks that the annotated string is a valid hex color.
IdenticalTo
Checks whether the annotated value is identical to another value.
InFuture
Checks whether the annotated date is in the future
ISBN
Checks that the annotated string is a valid ISBN. type determines the type of ISBN. The default is ISBN-13.
IsEmpty
Checks whether the annotated element is empty or null
IsFalse
The annotated element must be false or null
IsTrue
The annotated element must be true
Json
Checks that the annotated string is valid JSON.
LessThan
Checks whether the annotated value is less than the specified value.
LessThanOrEqual
Checks whether the annotated value is less than or equal to the specified maximum.
Lowercase
Checks that the annotated string is in lowercase.
Max
Checks whether the annotated value is less than or equal to the specified maximum.
Min
Checks whether the annotated value is higher than or equal to the specified minimum.
MongoId
Checks that the annotated string is a valid mongo id.
Negative
Checks if the element is strictly negative. Zero values are considered invalid.
NegativeOrZero
Checks if the element is negative or zero.
NotBlank
Checks that the annotated string is not null and the trimmed length is greater than 0.
NotEmpty
Checks whether the annotated element is not null nor empty
NotEqualTo
Checks whether the annotated value is not equal to another value.
NotIdenticalTo
Checks whether the annotated value is not identical to another value.
NotNull
Checks whether the annotated element is not null
Null
Checks whether the annotated element is null
Numeric
Checks that the annotated string is a valid number.
Past
Checks whether the annotated date is in the past
PastOrPresent
Checks whether the annotated date is in the past or in the present
Pattern
Checks if the annotated string matches the regular expression RegExp pattern.
Positive
Checks if the element is strictly positive. Zero values are considered invalid.
PositiveOrZero
Checks if the element is positive or zero.
Range
Checks whether the annotated value lies between (inclusive) the specified minimum and maximum
Size
Checks if the annotated element’s size is between min and max (inclusive)
Type
Checks whether the annotated element is of the declared type
Unique
Checks that the annotated collection only contains unique elements. The default message does not include the list of duplicate elements but you can include it by overriding the message and using the {duplicates} message parameter. The list of duplicate elements is also included in the dynamic payload of the constraint violation.
Uppercase
Checks that the annotated string is uppercase.
URL
Checks if the annotated string is a valid URL according to RFC2396. If any of the optional parameters protocol, host or port are specified, the corresponding URL fragments must match the specified values. The optional parameter regexp allow to specify an additional regular expression which the URL must match.
Uuid
Checks that the annotated string is a UUID. [...]
Valid
Checks that the annotated Type is valid. [...]

Constants

alpha → const Alpha
Alpha annotation using default values
const Alpha()
blank → const Blank
Blank annotation using default values
const Blank()
creditCardNumber → const CreditCardNumber
CreditCardNumber annotation using default values
email → const Email
Email annotation using default values
const Email()
future → const InFuture
InFuture annotation using default values
const InFuture()
futureOrPresent → const FutureOrPresent
FutureOrPresent annotation using default values
const FutureOrPresent()
hexadecimal → const Hexadecimal
Hexadecimal annotation using default values
const Hexadecimal()
hexcolor → const HexColor
HexColor annotation using default values
const HexColor()
isbn → const ISBN
ISBN annotation using default values
const ISBN()
isEmpty → const IsEmpty
IsEmpty annotation using default values
const IsEmpty()
isFalse → const IsFalse
IsFalse annotation using default values
const IsFalse()
isNull → const Null
Null annotation using default values
const Null()
isTrue → const IsTrue
IsTrue annotation using default values
const IsTrue()
json → const Json
Json annotation using default values
const Json()
lowercase → const Lowercase
Lowercase annotation using default values
const Lowercase()
mixedAnnotations → const List<Type>
const [Digits, Size]
mongoId → const MongoId
MongoId annotation using default values
const MongoId()
negative → const Negative
Negative annotation using default values
const Negative()
negativeOrZero → const NegativeOrZero
NegativeOrZero annotation using default values
const NegativeOrZero()
notBlank → const NotBlank
NotBlank annotation using default values
const NotBlank()
notEmpty → const NotEmpty
NotEmpty annotation using default values
const NotEmpty()
notNull → const NotNull
NotNull annotation using default values
const NotNull()
numeric → const Numeric
Numeric annotation using default values
const Numeric()
past → const Past
Past annotation using default values
const Past()
pastOrPresent → const PastOrPresent
PastOrPresent annotation using default values
const PastOrPresent()
positive → const Positive
Positive annotation using default values
const Positive()
positiveOrZero → const PositiveOrZero
PositiveOrZero annotation using default values
const PositiveOrZero()
unique → const Unique
Unique annotation using default values
const Unique()
uppercase → const Uppercase
Uppercase annotation using default values
const Uppercase()
url → const URL
URL annotation using default values
const URL()
uuid → const Uuid
Uuid annotation using default values
const Uuid()
valid → const Valid
Valid annotation using default values
const Valid()

Properties

basicAnnotations → List<Object>
final
choiceAnnotations → List
final
classLevelAnnotations → List<Type>
final
collectionAnnotations → List<Object>
final
comparisonAnnotations → List<Type>
final
dateAnnotations → List<Object>
final
fieldAnnotations → List
final
fileAnnotations → List
final
moneyAnnotations → List
final
numberAnnotations → List<Object>
final
stringAnnotations → List<Object>
final