SchemaClass -> SchemableClass
This commit is contained in:
17
src/newSchemable.ts
Normal file
17
src/newSchemable.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
type ParamsArgs = [] | [Partial<z.ParseParams>]
|
||||
|
||||
type NewEntityArgs<Input extends object> =
|
||||
HasRequiredKeys<Input> extends true
|
||||
? [Input, ...ParamsArgs]
|
||||
: [] | [Input, ...ParamsArgs]
|
||||
|
||||
|
||||
export const newEntity = <
|
||||
$Config extends EntityConfig,
|
||||
Static extends EntityClassStatic<$Config>,
|
||||
T extends Entity<$Config>,
|
||||
>(
|
||||
class_: EntityClass<$Config, Static, T>,
|
||||
...[values, params]: NewEntityArgs<$Config["input"]>
|
||||
) =>
|
||||
new class_(class_.schemaWithDefaultValues.parse(values || {}, params))
|
||||
Reference in New Issue
Block a user