Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,28 @@ const ConfigSchema = z
})
.refine(
(data) => {
// Either apiKey is present, or both username and password are present
return !!data.apiKey || (!!data.username && !!data.password);
// If username is provided, password must be provided
if (data.username) {
return !!data.password;
}

// If password is provided, username must be provided
if (data.password) {
return !!data.username;
}

// If apiKey is provided, it's valid
if (data.apiKey) {
return true;
}

// No auth is also valid (for local development)
return true;
},
{
message:
"Either ES_API_KEY or both ES_USERNAME and ES_PASSWORD must be provided",
path: ["apiKey", "username", "password"],
"Either ES_API_KEY or both ES_USERNAME and ES_PASSWORD must be provided, or no auth for local development",
path: ["username", "password"],
}
);

Expand Down