Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: Is it possible to make yup schema fully typed? #1073

Open
kentakozuka opened this issue Jun 26, 2024 · 0 comments
Open

UI: Is it possible to make yup schema fully typed? #1073

kentakozuka opened this issue Jun 26, 2024 · 0 comments

Comments

@kentakozuka
Copy link
Contributor

kentakozuka commented Jun 26, 2024

Describe the feature you'd like

If we use yup's test() and use the parent value to validate, context.from[1].value is any type. Is it possible to avoid any?

const variationsSchema = yup.array().of(
  yup
    .object()
    .shape({
      id: yup.string(),
      value: yup
        .string()
        .required()
        .test(
          'isNumber',
          intl.formatMessage(messages.input.error.notNumber),
          (value, context) => {
            if (
              context.from[1].value.variationType ==
              Feature.VariationType.NUMBER.toString()
            ) {
              return !isNaN(Number(value));
            }
            return true;
          }
        )
...

Background

No response

Alternative solutions

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant