Open hyunbinseo opened 4 weeks ago
same problem with nullable
, nullish
and optional
. How it should convert it to 0.31 version ?
// Before
const orgId = coerce(nullish(number([integer()])), toNumber),
// After
const orgId = pipe(unknown(), transform(toNumber)),
// Expected - for nullish, optional, nullable, I can't find example with pipe :
nullish(pipe(unknown(), transform(toNumber), number(), integer()));
// OR
pipe(nullish(), unknown(), transform(toNumber), number(), integer());
@throrin19 I believe this is the correct usage,
import { integer, nullish, number, pipe, transform, unknown } from 'valibot';
const Schema = nullish(pipe(unknown(), transform(Number), number(), integer()));
since pipe()
results in a schema. It can be placed in the v.string()
place.
// Example from https://valibot.dev/api/nullable/
const NullableStringSchema = v.nullable(v.string(), "I'm the default!");
Thank you for your feedback! I will look into it!
Codemod:
valibot/migrate-to-v0.31.0@0.2.1