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

Modify tupleAsync schema items reference more precise #649

Conversation

chimame
Copy link
Contributor

@chimame chimame commented Jun 12, 2024

Overview

The items specified when generating a tupleAsync schema are curried. So I wrote this fix.

Details

This change is for the same reason as the previous change to the variant schema. #600

I have created code that reproduces this issue.

import * as v from 'valibot';

const Schema = v.tupleAsync([v.number(), v.string()]);

const convertSchema = {
  ...Schema,
  items: Schema.items.map((item) => {
    v.pipeAsync(
      v.unknown(),
      v.transform((output) => {
        console.log('not execute')
        return output == null ? 0 : output
      }),
      item,
    )
  })
}

console.log('start parse')
const result = await v.safeParseAsync(convertSchema, [null, 'test']);
console.log('end parse')

console.log(result); // <-- parse error

@chimame chimame force-pushed the modify-tuple-async-schema-items-references-more-precise branch from a649622 to 9a1529e Compare June 12, 2024 16:25
@fabian-hiller fabian-hiller self-assigned this Jun 12, 2024
@fabian-hiller fabian-hiller added the fix A smaller enhancement or bug fix label Jun 12, 2024
@fabian-hiller
Copy link
Owner

Thank you! I will review and merge it soon.

@fabian-hiller fabian-hiller force-pushed the modify-tuple-async-schema-items-references-more-precise branch from 54febe1 to a7dcdc0 Compare June 12, 2024 21:45
@fabian-hiller fabian-hiller merged commit 600b083 into fabian-hiller:main Jun 12, 2024
6 checks passed
@chimame chimame deleted the modify-tuple-async-schema-items-references-more-precise branch June 13, 2024 00:06
@fabian-hiller
Copy link
Owner

v0.32.0 is available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix A smaller enhancement or bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants