Type for Flatten Error #640
Answered
by
fabian-hiller
ksjitendra18
asked this question in
Q&A
-
Hey there. What should be the type for flat error. In this I am current manually typing it. const [error, setError] = createSignal<FlatErrors<"name" | "email"> | null>(
null,
);
if (result.success) {
console.log(result.output);
} else {
const err = flatten<typeof RegisterSchema>(result.issues);
setError(err);
} Here is the schema const RegisterSchema = object({
name: pipe(
string(),
nonEmpty("Please enter your name."),
minLength(2, "Name should be 2 or more than 2 character"),
maxLength(48, "Name should be less than"),
trim(),
),
email: pipe(
string(),
nonEmpty("Please enter your email."),
email("Please enter a valid email address"),
),
});
export default RegisterSchema;
export type RegisterData = InferOutput<typeof RegisterSchema>; Need help regarding this. |
Beta Was this translation helpful? Give feedback.
Answered by
fabian-hiller
Jun 14, 2024
Replies: 1 comment 4 replies
-
I agree that the current implementation is not perfect. I will probably change it back to |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A new version with the fix is available.