resolvers icon indicating copy to clipboard operation
resolvers copied to clipboard

[React Native] Zod v4 locale and global error customization not picked up

Open KoenCa opened this issue 5 months ago • 0 comments

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:

Version Number

5.1.1

Codesandbox/Expo snack

https://github.com/KoenCa/expo-zod-repro

Steps to reproduce

  1. Install dependencies with bun install
  2. Run the server with bun start
  3. Open in simulator/device of your choice
  4. 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.
  5. In the metro.config.js file uncomment config.resolver.unstable_enablePackageExports = false;, save and restart the server.
  6. Reload the app on your simulator/device
  7. 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

KoenCa avatar Jun 19 '25 15:06 KoenCa