validate method
Implementation
@override
JarResult validate(dynamic value,
[Map<String, dynamic>? allValues, String? path, Object? root]) {
final base = super.validate(value, allValues, path, root ?? value);
if (!base.isValid) return base;
if (schemas.isEmpty) return JarResult.success(value);
JarResult? firstFailure;
for (final schema in schemas) {
final result = schema.validate(value, allValues, path, root ?? value);
if (result.isValid) return JarResult.success(result.value);
firstFailure ??= result;
}
return JarResult.error(
firstFailure?.error ?? 'No matching schema in union');
}