Effect CommunityEC
Effect Community2y ago
28 replies
Nanniiii

Handling Required Fields Without Default Values in Form Schema Validation

i have a more general question about schema validation when it comes to forms. how to you handle the use cases where a field is required by the api so the form can only be valid if there is a value but since you want to show the placeholder of the input, you don't want a default value, so the type of the form with effect/schema becomes wrong.

i feel like it's a common case so must be a way to deal with that?

only way i can think of is make the schema accept NullOr on every value and in the onSubmit, actually validate that it's not empty ?
Was this page helpful?