-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from jansedlon/main
- Loading branch information
Showing
9 changed files
with
37 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,11 @@ | ||
import { coerce, picklist } from 'valibot' | ||
import { | ||
type BaseSchema, | ||
type OptionalSchema, | ||
type Output, | ||
transform, | ||
} from 'valibot' | ||
import { boolean, pipe, string, union } from 'valibot' | ||
import { transform } from 'valibot' | ||
|
||
export function withDefault<Schema extends OptionalSchema<BaseSchema>>( | ||
schema: Schema, | ||
value: Output<Schema['wrapped']> | ||
) { | ||
return transform(schema, (val) => val ?? value) | ||
} | ||
export const BooleanInStr = pipe( | ||
union([string(), boolean()]), | ||
transform((value) => { | ||
if (typeof value === 'string') return value.toLowerCase() === 'true' | ||
|
||
export const BooleanInStr = transform( | ||
coerce(picklist(['true', 'false']), (value) => { | ||
if (typeof value !== 'string') return value | ||
return value.toLowerCase() | ||
}), | ||
(value) => value === 'true' | ||
return value | ||
}) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 5 additions & 4 deletions
9
packages/generator/src/shared/generator-context/module-resolution.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters