From 80bfebf0e0fa372d06c1712fa55f7dbf6a67c652 Mon Sep 17 00:00:00 2001 From: Owen Melbourne Date: Fri, 24 May 2024 10:49:54 +0100 Subject: [PATCH 1/2] bug fixed validation on props --- src/utils.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index e5a2387..f74f98a 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -186,19 +186,14 @@ export const checkOptions = ({ prefixes: Record; appsWhiteList: string[] | null | undefined; }): void => { - if (!latitude || !longitude) { + if ((!latitude && !longitude) || !address) { throw new MapsException( - '`showLocation` should contain keys `latitude` and `longitude`.', + '`latitude` & `longitude` or `address` is required. Both cannot be undefined.', ); } if (address && typeof address !== 'string') { throw new MapsException('Option `address` should be of type `string`.'); } - if (!latitude && !longitude && !address) { - throw new MapsException( - '`latitude` & `longitude` or `address` is required. Both cannot be undefined.', - ); - } if (title && typeof title !== 'string') { throw new MapsException('`title` should be of type `string`.'); } From 526152b84cec210b543ac0433d64c39607550b9b Mon Sep 17 00:00:00 2001 From: Thomas Schoffelen Date: Tue, 18 Jun 2024 17:16:07 +0200 Subject: [PATCH 2/2] Update src/utils.ts --- src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index 2822e55..dc2eaf2 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -186,7 +186,7 @@ export const checkOptions = ({ prefixes: Record; appsWhiteList: string[] | null | undefined; }): void => { - if ((!latitude && !longitude) || !address) { + if (!(latitude && longitude) && !address) { throw new MapsException( '`latitude` & `longitude` or `address` is required. Both cannot be undefined.', );