Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
fix(postal-code-lookup): move length check to verify spec
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianAndersen committed Jul 7, 2024
1 parent 3aa2b60 commit 859630a
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export function verifyPostalCodeLookupSpec(
postalCodeSpec: unknown,
): postalCodeSpec is PostalCodeLookupSpec {
const m = postalCodeSpec as Record<string, unknown> | null | undefined;
return !!m && typeof m["postalCode"] === "string";
return (
!!m && typeof m["postalCode"] === "string" && m["postalCode"].length !== 4
);
}

export class PostalCodeLookupOperation implements Operation {
Expand All @@ -44,9 +46,6 @@ export class PostalCodeLookupOperation implements Operation {
if (!verifyPostalCodeLookupSpec(postalCodeLookupSpec)) {
throw new BlError(`Malformed PostalCodeSpec`).code(701);
}
if (postalCodeLookupSpec.postalCode.length !== 4) {
return new BlapiResponse([{ postalCity: null }]);
}
const bringAuthHeaders = {
"X-MyBring-API-Key": process.env["BRING_API_KEY"],
"X-MyBring-API-Uid": process.env["BRING_API_ID"],
Expand Down

0 comments on commit 859630a

Please sign in to comment.