ZObject<T extends Object> class
Schema type representing an Object of type T
.
Wraps a schema to validate the object structure according to the provided schema
and maps parsed data to type T
using fromJson
.
Example:
Constructors
-
ZObject.withMapper(ZSchema schema, {required ObjectMapper<
T> fromJson}) -
Factory constructor that creates a new instance using the given
schema
for parsing and thefromJson
function for mapping parsed data to typeT
.factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isNullable → bool
-
Returns
true
ifnull
is allowed as a valid input.no setterinherited - isOptional → bool
-
Returns
true
if the value can be omitted from the input.no setterinherited - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
nullable(
) → ZNullableObject< T> -
Enable
null
value. All rules will be skipped for null values. -
optional(
) → ZNullableObject< T> - Enable omitting this value. All rules will be skipped if the value is missing.
-
parse(
Object? val) → ZRes< T> -
Parses
val
using the configured transformation pipeline and returns a ZRes containing either the successfully parsed value or a validation error.inherited -
process(
Processor< T> processor) → ZObject<T> -
Adds a custom processing of a value using
processor
. -
refine(
Refiner< T> refiner, {String? message, String? code}) → ZObject<T> -
Adds a custom refinement to ensure the value satisfies the given
refiner
. -
superRefine(
SuperRefiner< T> refiner) → ZObject<T> -
Adds a check to ensure that the value satisfies the given
refiner
. -
toObj<
To extends Object> (Transformer< T, To> transformer) → ZObject<To> -
Adds a transformation of current type
T
to an object of typeTo
using custom transformer. -
toStr(
Transformer< T, String> transformer) → ZString -
Adds a transformation of current
T
value to String using custom transformer. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited