must_be library

Classes

Blank
Represents the constraint when a String must be a valid brazilian mobile landline phone number.
Constraint
Default constraint.
CreditCard
Represents the constraint when a String must be a valid brazilian mobile landline phone number.
Email
Represents the constraint when a String must be an email.
Empty
Represents the constraint when a value must be empty.
EndedWith
Represents the constraint when a String must be ended with the end.
Equal<T extends Object>
Represents the constraint when a value must be equal to another value.
GreaterThan<T extends Object>
Represents the constraint when a value must be greater than another value.
GreaterThanOrEqualTo<T extends Object>
Represents the constraint when a value must be greater than or equal to another value.
GreaterThanOrEqualToToday
Represents the constraint when a DateTime must be greater or equal to today DateTime.now.
GreaterThanToday
Represents the constraint when a DateTime must be greater than today DateTime.now.
Invalid
Default constraint.
LessThan<T extends Object>
Represents the constraint when a value must be less than another value.
LessThanOrEqualTo<T extends Object>
Represents the constraint when a value must be less than or equal to another value.
LessThanOrEqualToToday
Represents the constraint when a DateTime must be less or equal to today DateTime.now.
LessThanToday
Represents the constraint when a DateTime must be less that today DateTime.now.
Match
Represents the constraint when a String must have a match with a regex.
NotBlank
Represents the constraint when a String must be not blank.
NotEmpty
Represents the constraint when a value must be not empty.
NotEqual<T extends Object>
Represents the constraint when a value must be not equal to another value.
NotNull
Represents the constraint when a value is must be not null.
NotSameDay
Represents the constraint when a DateTime not must have the same day as the other DateTime.
NotSameToday
Represents the constraint when a DateTime must not be the same day as the current date.
Null
Represents the constraint when a value must be null.
OnlyNumbers
Represents the constraint when a String must have only numbers.
Require<T>
Class to create a requirement of how a value must be mustBe.
SameDay
Represents the constraint when a DateTime must have the same day as the other DateTime.
SameToday
Represents the constraint when a DateTime must be the same day as the current dateDateTime.now.
StartedWith
Represents the constraint when a String must be started with the start.
Url
Represents the constraint when a String must be a url.
ValidationsLocalization
Translate constraint message when called validate function.
ZipCode
Represents the constraint when a String must be a valid brazilian mobile landline phone number.

Extensions

RequireAll on Require<T?>
Extension for the validation of the Object type. if the value is null, then an exception never will throw.
RequireBrString on Require<T?>
Extension for the validation of the String type.
RequireDate on Require<T?>
Extension for the validation of the DateTime type. if the value is null, then an exception never will throw.
RequireDouble on Require<T?>
Extension for the validation of the double type. if the value is null, then an exception never will throw.
RequireInt on Require<T?>
Extension for the validation of the int type. if the value is null, then an exception never will throw.
RequireList on Require<T?>
Extension for the validation of the List type. if the value is null, then an exception never will throw.
RequireNotNull on Require<T?>
Extension for the validation of the null type.
RequireNumber on Require<T?>
Extension for the validation of the num type. if the value is null, then an exception never will throw.
RequireString on Require<T?>
Extension for the validation of the String type. If the value is null, then an exception never will throw.

Functions

requireThat<T>(T value, {String? name}) Require<T>
Descriptive way to create a Require.
throwsConstraintException<T extends Constraint>({String? name, String? constraintMessage, Object? value}) → Matcher
Helper function to test the ConstraintException thrown.
validate(void validation(), {String? ifNotValid(ConstraintException constraintError)?}) String?
Calls validation function and if thrown an ConstraintException then the ifNotValid function is called if null then the translation is called, otherwise, nothing occurs.

Typedefs

OnConstraintException = String Function(ConstraintException constraintException)
Function used for the customizes the constraint message.

Exceptions / Errors

ConstraintException
Exception thrown when a value violates a constraint. Use a name to name the value.