runPreprocessors method
Runs the synchronous preprocessor chain registered via preprocess
against value and returns the result. Does NOT run _resolveNull,
validators, or transforms — only the preprocess stage.
Useful for consumers that need to mirror the schema's preprocess
stage in their own scoped pipeline. For example, valiform calls
this on a VMap / VObject to apply container-level preprocess
before running per-field validators (matching the order
safeParse uses internally).
Throws VAsyncRequiredException when the schema has any async preprocessor — use runPreprocessorsAsync instead.
final schema = V.string().preprocess((v) => (v as String).trim());
schema.runPreprocessors(' hi '); // 'hi'
Implementation
Object? runPreprocessors(Object? value) {
if (_asyncPreprocessors.isNotEmpty) {
throw const VAsyncRequiredException(
methodName: 'runPreprocessors',
suggestion: 'runPreprocessorsAsync',
);
}
Object? input = value;
for (final fn in _preprocessors) {
input = fn(input);
}
return input;
}