GuardExtensions extension
Methods
-
indexOutOfRange(int input, Iterable values, {String? name})
→ int
-
Throws a RangeError if
input
is not a valid enum index. Returns input
otherwise.
-
invalidFormat(String input, String regexPattern, {String? name, String? message, bool caseSensitive = true, bool multiline = false})
→ String
-
Throws an ArgumentError if
input
doesn't match the regexPattern
.
Returns input
otherwise.
-
invalidInput<T>(T input, bool predicate(T), {String? name, String? message})
→ T
-
Throws an ArgumentError if
input
doesn't satisfy the predicate function.
Returns input
otherwise.
-
negative<T extends num>(T input, {String? name, String? message})
→ T
-
Throws an ArgumentError if
input
is negative. Returns input
otherwise.
-
negativeOrZero<T extends num>(T input, {String? name, String? message})
→ T
-
Throws an ArgumentError if
input
is negative or zero. Returns input
otherwise.
-
nullOrEmpty(String? input, {String? name, String? message})
→ String
-
Throws an ArgumentError if
input
is null or empty. Returns input
otherwise.
-
nullOrEmptyCollection<T extends Iterable>(T? input, {String? name, String? message})
→ T
-
Throws an ArgumentError if
input
is null or an empty collection. Returns input otherwise.
-
nullOrInvalidInput<T>(T? input, bool predicate(T?), {String? name, String? message})
→ T
-
Throws an ArgumentError if
input
is null or doesn't satisfy the predicate
function.
Returns input
otherwise.
-
nullOrWhitespace(String? input, {String? name, String? message})
→ String
-
Throws an ArgumentError if
input
is null, empty, or white space. Returns input
otherwise.
-
nullValue<T>(T input, {String? name})
→ T
-
Throws an ArgumentError if
input
is null. Returns input
otherwise.
-
outOfRange<T extends Comparable>(T input, T rangeFrom, T rangeTo, {String? name, String? message})
→ T
-
Throws a RangeError if
input
is less than rangeFrom
or greater than rangeTo
.
Returns input
otherwise.
-
outOfRangeItems<T extends Iterable, U extends Comparable>(T input, U rangeFrom, U rangeTo, {String? name, String? message})
→ T
-
Throws an ArgumentError if any
input
item is less than rangeFrom
or greater than rangeTo
.
Returns input
otherwise.
-
zero<T extends num>(T input, {String? name, String? message})
→ T
-
Throws an ArgumentError if
input
is zero. Returns input
otherwise.