refinedev/refine

[FEAT] Antd | Allow translation for required field messages

oscarviq opened this issue · 2 comments

Is your feature request related to a problem? Please describe.

Looks like the rules for form validation in the auth page component's do not allow for setting translated messages to the auth components. This is also true for the register, forgot password, etc. pages.

<Form.Item
            name="email"
            label={translate("pages.login.fields.email", "Email")}
            rules={[
              { required: true },
              {
                type: "email",
                message: translate(
                  "pages.login.errors.validEmail",
                  "Invalid email address",
                ),
              },
            ]}
          >

Screenshot 2024-04-15 at 5 27 32 PM

Describe alternatives you've considered

No response

Additional context

No response

Describe the thing to improve

From the looks of Antd's documentation, you can also pass a message property to the "required" rule:

https://ant.design/components/form#components-form-demo-normal-login

Hello @oscarviq, thanks for the issue. As you said, we need to give the message prop to the required prop.

I will write what needs to be done step by step. please let me know if I missed anything.

Implementation details

code example:

{
  required: translate(
    "pages.login.errors.requiredEmail",
    "Email is required",
  ),
},

Hey @oscarviq I wish to contribute to this
Please assign the issue to me