Hook's are basically structs with methods but it would be really helpful if the hook could also be a static type. For instance:
MyType<-:
type: str
validator:
return->: v --if "v in ['foo','bar']"
MyHook:
foo: MyHookType
Here we see a hook which is just a string and has a validator to go with. In this case, we can't have extra fields as then a field named type would be mangled as some type hook. Should also qualify the default of type as again, the user might have a hook which has a single type field which might have some default that makes no sense and the intention is again some map that has a key with a default type looking value.
This needs to be done with some typing_extensions.Annotated use where we are really just creating some validator I think.
Hook's are basically structs with methods but it would be really helpful if the hook could also be a static type. For instance:
Here we see a hook which is just a string and has a validator to go with. In this case, we can't have extra fields as then a field named
type
would be mangled as some type hook. Should also qualify the default oftype
as again, the user might have a hook which has a singletype
field which might have some default that makes no sense and the intention is again some map that has a key with a default type looking value.This needs to be done with some
typing_extensions.Annotated
use where we are really just creating some validator I think.