Code Monkey home page Code Monkey logo

Comments (3)

ixTec avatar ixTec commented on June 16, 2024

Building on this, it looks like the errors do not respect the locale set by the I18nProvider - see:
Screenshot 2024-04-19 at 17 06 32

Note that the locale is set to es-ES, and you can see the DateField has the correct format for the locale (no leading zero), but the error is in English and has the incorrect format (it has a leading zero)

from react-spectrum.

reidbarber avatar reidbarber commented on June 16, 2024

Those error messages are the browser's built-in validation messages, so they rely on the browser's set language, not the provider's locale. There isn't currently a browser API for customizing this behavior. You can pass in custom error messages as an alternative instead: https://react-spectrum.adobe.com/react-spectrum/forms.html#customizing-error-messages

from react-spectrum.

ixTec avatar ixTec commented on June 16, 2024

Oh that's a shame. Is there a straightforward way to extract the date value from from the error? Or would regex be my only bet? Or should the date have the correct locale format already?

The main problem is the date not using the correct locale (and therefore causing client/server mismatch errors), so if I could easily extract this and format it correctly, then it wouldn't be a big of a concern.

Right now the server/client mismatch is our block.

EDIT: I suppose I could use the minValue/maxValue provided to the component, but this wouldn't give me the original browser-provided error message when using validationDetails to specify it on the validationDetails.rangeOverflow / rangeUnderflow and so I'd have to provide a custom (and therefore may as well translate) message itself

from react-spectrum.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.