Skip to main content

Parsing values

Strict mode​

By default, ZodArt parsers operate in strict mode. This means they will only accept input values that match the expected type exactly. Any type mismatch will result in a ParseError.

The only exception is ZObject, which accepts only Map<String, dynamic> as input.

➑️input ⬇️outputListboolDateTimedoubleintMap<String, dynamic>Stringothers
ZArrayβœ…βŒβŒβŒβŒβŒβŒβŒ
ZBoolβŒβœ…βŒβŒβŒβŒβŒβŒ
ZDateTimeβŒβŒβœ…βŒβŒβŒβŒβŒ
ZDoubleβŒβŒβŒβœ…βŒβŒβŒβŒ
ZIntβŒβŒβŒβŒβœ…βŒβŒβŒ
ZObjectβŒβŒβŒβŒβŒβœ…βŒβŒ
ZStringβŒβŒβŒβŒβŒβŒβœ…βŒ

🚧 Parsing with coertion parameter (coertion: true)​

⚠️ Coercion support will be implemented in future versions. For now, when parsing data from forms or loosely typed sources, please use explicit transformation chains, e.g. ZString().toInt().

When the coercion option is enabled, ZodArt will attempt to convert compatible input values automatically, if there's no risk of data loss.

  • βœ… int -> double is allowed (safe upcast)
  • ❌ double -> int is not allowed (precision loss risk)
  • ⚠️ Strings will be parsed using Dart's native .parse() methods (e.g., int.parse, DateTime.parse)

This is especially useful for form data or serialized values.

➑️input ⬇️outputListboolDateTimedoubleintMap<String, dynamic>Stringothers
ZArrayβœ…βŒβŒβŒβŒβŒβŒβŒ
ZBoolβŒβœ…βŒβŒβŒβŒβš οΈ true / false (case-insensitive)❌
ZDateTimeβŒβŒβœ…βŒβŒβŒβš οΈDateTime.parse❌
ZDoubleβŒβŒβŒβœ…βœ…βŒβš οΈdouble.parse❌
ZIntβŒβŒβŒβŒβœ…βŒβš οΈint.parse❌
ZObjectβŒβŒβŒβŒβŒβœ…βŒβŒ
ZStringβŒβŒβŒβŒβŒβŒβœ…βŒ