effect
effect copied to clipboard
Add a Schema.config for decoding Configs using a Schema.
What is the problem this feature would solve?
It would be convenient to be able to use a Schema instead one of the built in Config primitives for decoding a Config var.
What is the feature you are proposing to solve the problem?
Add a Schema.config :: (Schema<A, string, R>, name?: string) -> Effect<Config<A>, never, R> function.
What alternatives have you considered?
None.
I think this should wait until schema is part of "effect", as it seems like an api that should be owned by the Config module.
I'm using this at the moment :
import * as S from '@effect/schema/Schema';
import { EmailAddress } from 'my-domain';
const EmailAddressConfig = flow(
Config.string,
Config.validate({
message: 'Expected a valid EmailAddress',
validation: S.is(EmailAddress),
})
);
const AdminEmailAddressConfig = EmailAddressConfig('ADMIN_EMAIL_ADDRESS');
@vecerek @jessekelly881 impl here, feel free to leave any comments: https://github.com/Effect-TS/effect/pull/2816