Skip to content

Commit

Permalink
feat(vh): uuid util
Browse files Browse the repository at this point in the history
  • Loading branch information
sandros94 committed Dec 13, 2024
1 parent e4622d5 commit 71a90b0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import {
checkboxAsString,
intAsString,
numAsString,
uuid,
} from './schemas'

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

export {
Expand Down
11 changes: 11 additions & 0 deletions src/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,14 @@ export const numAsString = v.pipe(
v.decimal('Must be a number string'),
v.transform(Number),
)

/**
* Valibot schema to parse strings that are valid UUID.
* @example
* ```ts
* v.parse(vh.uuid, '2') -> throws an error
*/
export const uuid = v.pipe(
v.string(),
v.uuid(),
)

0 comments on commit 71a90b0

Please sign in to comment.