Skip to content

Commit

Permalink
fix: image validation
Browse files Browse the repository at this point in the history
  • Loading branch information
BohdanK-W32 committed Oct 17, 2023
1 parent 40aa057 commit 2039f5e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/hooks/checkImageAspectRatio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export const checkImageAspectRatio =
async ({ data }) => {
const imageAspectRatio = data?.width / data?.height;
const requiredAspectRatio = x / y;
const isValidAspectRatio = imageAspectRatio - requiredAspectRatio < 0.001;
const isValidAspectRatio =
imageAspectRatio - requiredAspectRatio > -0.001 && imageAspectRatio - requiredAspectRatio < 0.001;

if (!isValidAspectRatio) throw new Error(`Image aspect ratio must be ${x}:${y}`);
};

0 comments on commit 2039f5e

Please sign in to comment.