How to return the same error message regardless of the specific error #467
sacrosanctic
started this conversation in
General
Replies: 2 comments 3 replies
-
You can overwrite the message globally with |
Beta Was this translation helpful? Give feedback.
2 replies
-
Update: Any schema and action has its own error message: const RecordSchema = v.record(v.string('key error'), v.pipe(v.string('value error'), v.decimal('decimal error')), 'object error'); If you want the same error message for all nested schemas you can use the const RecordSchema = v.config(v.record(v.string(), v.string()), { message: 'error' }); If you want the same error message for all schemas when using const RecordSchema = v.record(v.string(), v.string());
const output = v.parse(RecordSchema, data, { message: 'error' }); If you want the same error message for all schemas globally you can use v.setGlobalMessage('error'); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, I have to write out the same msg for every fn in the pipe.
Beta Was this translation helpful? Give feedback.
All reactions