ZInt Schema Documentation
The ZInt class is a schema used for validating integer values in the zard package. It extends the Schema<int> base class and provides a variety of validation methods for integers.
Constructor ZInt({String? message})
Initializes a new instance of ZInt with an optional custom error message if the value is not a valid integer.
Example:
final value = z.int.parse(7); // returns 7Methods
min
min(int length, {String? message});
Validates that the int has at least the specified minimum number of characters.
Example:
final schema = z.int().min(10);
final number = schema.parse(15); // returns 15
final number = schema.parse(5); // returns ZardErrormax
max(int length, {String? message});
Validates that the int has no more than the specified maximum number of characters.
Example:
final schema = z.int().max(10);
final number = schema.parse(5); // returns 5
final number = schema.parse(15); // returns ZardErrorpositive
positive({String? message});
Validates that the int is positive (> 0).
Example:
final schema = z.int().positive();
final number = schema.parse(5); // returns 5
final number = schema.parse(-5); // returns ZardErrornonnegative
nonnegative({String? message});
Validates that the int is nonnegative (>= 0).
Example:
final schema = z.int().nonnegative();
final number = schema.parse(5); // returns 5
final number = schema.parse(0); // returns 0
final number = schema.parse(-5); // returns ZardErrornegative
negative({String? message});
Validates that the int is negative (< 0).
Example:
final schema = z.int().negative();
final number = schema.parse(-5); // returns -5
final number = schema.parse(10); // returns ZardErrormultipleOf
multipleOf(int divisor, {String? message})
Validates that the int is a multiple of the specified divisor.
Example:
final schema = z.int().multipleOf(3);
final number = schema.parse(6); // returns 6
final number = schema.parse(9); // returns 9
final number = schema.parse(7); // returns ZardErrorstep
step(int stepValue, {String? message})
Alist Validates that the int is a divisible by the specified step value.
Example:
final schema = z.int().step(3);
final number = schema.parse(6); // returns 6
final number = schema.parse(9); // returns 9
final number = schema.parse(7); // returns ZardError