Map<String, Object?> toJson() => { 'isValid': isValid, if (value != null) 'value': value, if (!isValid) 'errors': expectations.map((e) => e.toJson()).toList(growable: false), };