Validart class

The Validart class is the entry point for defining validation rules.

It provides a fluent API for validating different data types, including:

  • Strings (VString)
  • Booleans (VBool)
  • Integers (VInt)
  • Doubles (VDouble)
  • Numeric values (VNum)
  • Maps (VMap)
  • Date (VDate)

This class enables custom validation rules and supports chaining for complex validation logic.

Example

final v = Validart();

final validator = v.string().min(5).max(20);

print(validator.validate('Hello')); // true
print(validator.validate('Hi')); // false (too short)
Available extensions

Constructors

Validart({Message? message})
Creates an instance of Validart for managing validations.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

bool({String? message}) VBool
Creates a VBool instance for validating boolean values.
date({String? message}) VDate
Creates a VDate instance for validating date values.
double({String? message}) VDouble
Creates a VDouble instance for validating floating-point values.
form(VMap map, {GlobalKey<FormState>? formKey, Map<String, dynamic>? defaultValues}) VForm

Available on Validart, provided by the ValidartExtension extension

Creates a VForm from a VMap validation schema.
int({String? message}) VInt
Creates a VInt instance for validating integer values.
map(Map<String, VType> object, {String? message}) VMap
Creates a VMap instance for validating objects with structured keys.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
num({String? message}) VNum
Creates a VNum instance for validating generic numeric values (int or double).
string({String? message}) VString
Creates a VString instance for validating string values.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited