Skip to content

Commit

Permalink
fix: vh schemas jsdocs
Browse files Browse the repository at this point in the history
  • Loading branch information
sandros94 committed Jan 25, 2025
1 parent d99ee51 commit 16a8899
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export {
type VSchema,
} from './parsers'

export * as vh from './schemas'
export * from './schemas'

export * as v from 'valibot'
20 changes: 15 additions & 5 deletions src/core/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as v from 'valibot'

/**
* Valibot schema to parse strings that are booleans.
* Use to parse <input type="hidden" value="true" /> values.
* Use to parse `<input type="hidden" value="true" />` values.
* @example
* ```ts
* v.parse(boolAsString, 'true') -> true
Expand All @@ -17,7 +17,7 @@ export const boolAsString = v.pipe(

/**
* Valibot schema to parse checkbox formdata.
* Use to parse <input type="checkbox" /> values.
* Use to parse `<input type="checkbox" />` values.
* @example
* ```ts
* v.parse(checkboxAsString, 'on') -> true
Expand All @@ -31,7 +31,7 @@ export const checkboxAsString = v.optional(v.pipe(

/**
* Valibot schema to parse strings that are integers.
* Use to parse <input type="number" /> values.
* Use to parse `<input type="number" />` values.
* @example
* ```ts
* v.parse(intAsString, '3') -> 3
Expand All @@ -45,7 +45,7 @@ export const intAsString = v.pipe(

/**
* Valibot schema to parse strings that are numbers.
* Use to parse <input type="number" step="0.1" /> values.
* Use to parse `<input type="number" step="0.1" />` values.
* @example
* ```ts
* v.parse(numAsString, '3.14') -> 3.14
Expand All @@ -59,7 +59,7 @@ export const numAsString = v.pipe(

/**
* Valibot schema to parse strings that are dates or datetime in ISO format.
* Use to parse <input type="date" /> and <input type="datetime-local" /> values.
* Use to parse `<input type="date" />` and `<input type="datetime-local" />` values.
* @example
* ```ts
* v.parse(dateAsString, '2022-01-01') -> new Date('2022-01-01')
Expand Down Expand Up @@ -101,3 +101,13 @@ export const email = v.pipe(
v.string(),
v.email(e => `Must be a valid Email, received: ${e.received}`),
)

export const vh = {
boolAsString,
checkboxAsString,
intAsString,
numAsString,
dateAsString,
uuid,
email,
}

0 comments on commit 16a8899

Please sign in to comment.