Skip to content

Commit 4e374aa

Browse files
authored
fix(config.ts): pass config object to configValidators[CONFIG_KEYS.OCO_OPENAI_API_KEY] to allow access to other config values (#225)
* any length `OCO_OPENAI_API_KEY` if `OCO_OPENAI_BASE_PATH` is set
1 parent ef003bd commit 4e374aa

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/commands/config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const validateConfig = (
4545
};
4646

4747
export const configValidators = {
48-
[CONFIG_KEYS.OCO_OPENAI_API_KEY](value: any) {
48+
[CONFIG_KEYS.OCO_OPENAI_API_KEY](value: any, config?: any) {
4949
validateConfig(CONFIG_KEYS.OCO_OPENAI_API_KEY, value, 'Cannot be empty');
5050
validateConfig(
5151
CONFIG_KEYS.OCO_OPENAI_API_KEY,
@@ -54,7 +54,7 @@ export const configValidators = {
5454
);
5555
validateConfig(
5656
CONFIG_KEYS.OCO_OPENAI_API_KEY,
57-
value.length === 51,
57+
config[CONFIG_KEYS.OCO_OPENAI_BASE_PATH] || value.length === 51,
5858
'Must be 51 characters long'
5959
);
6060

@@ -179,7 +179,7 @@ export const getConfig = (): ConfigType | null => {
179179
try {
180180
const validator = configValidators[configKey as CONFIG_KEYS];
181181
const validValue = validator(
182-
config[configKey] ?? configFromEnv[configKey as CONFIG_KEYS]
182+
config[configKey] ?? configFromEnv[configKey as CONFIG_KEYS], config
183183
);
184184

185185
config[configKey] = validValue;

0 commit comments

Comments
 (0)