resolvers
resolvers copied to clipboard
[React Native] Zod v4 locale and global error customization not picked up
Zod locales and global error customization are not working correctly due to new Metro ES Module resolution. All error messages are "Invalid input" instead of the configured messages from Zod locales or global config.
Info:
- Metro ES Module resolution docs
- https://github.com/expo/expo/discussions/36551
Version Number
5.1.1
Codesandbox/Expo snack
https://github.com/KoenCa/expo-zod-repro
Steps to reproduce
- Install dependencies with
bun install - Run the server with
bun start - Open in simulator/device of your choice
- In app press
Submit-> "Invalid input" message is shown- NOT correct. By default Zod should load its own en locale for messages or custom global config.
- In the
metro.config.jsfile uncommentconfig.resolver.unstable_enablePackageExports = false;, save and restart the server. - Reload the app on your simulator/device
- In app press
Submit-> "Too small: expected string to have >=1 characters" message is shown.- This is the expected behavior.
Expected behaviour
The correct Zod error messages should be passed to React hook form from the Zod schema resolver so that Zod locales or global customization is possible.
With new Metro ES Module resolution
Without new Metro ES Module resolution
Code of Conduct
- [x] I agree to follow this project's Code of Conduct