Callbacks
Handle success and validation errors with onSuccess and onError.
Use onSuccess and onError to react to the result of loading, for example when you don't await the promise.
import { } from 'zod';
import { } from 'zod-config';
const = .({
: .().(/^\d+$/),
: .(),
});
({
: ,
: () => {
.('An error occurred while loading the configuration:', );
},
: () => {
.('Configuration loaded successfully:', );
},
});onError receives the Zod error. When you pass it, the validation error is handled by your callback instead of being thrown.