-
Notifications
You must be signed in to change notification settings - Fork 78
Open
Labels
Status: Needs TriageIssue will be reviewed by Core Team and a relevant label will be added as soon as possibleIssue will be reviewed by Core Team and a relevant label will be added as soon as possible
Description
I am currently working on a project where we heavily use the effect/schema library. To avoid adding another dependency for form validation, I have implemented a new resolver.
I believe this could be interesting and useful for others as well.
Would you consider accepting a merge request that adds this new resolver?
Here is a quick demo of how it works so far:
- define a schema
const FORM_SCHEMA = Schema.Struct({
id: Schema.String,
startDate: Schema.DateFromSelf,
endDate: Schema.DateFromSelf.pipe(
Schema.annotations({ message: () => 'Please inter a valid Date or select a Date with the DatePicker' }),
),
reason: Schema.String.pipe(
Schema.minLength(4),
Schema.annotations({ message: () => 'Has to be at least 4 chars long' }),
),
})- use the custom resolver with full support of the
ParseOptionsObject from effect/schema
const resolver = ref(effectSchemaResolver(FORM_SCHEMA, { errors: 'all' }))- example of the error message

Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Status: Needs TriageIssue will be reviewed by Core Team and a relevant label will be added as soon as possibleIssue will be reviewed by Core Team and a relevant label will be added as soon as possible