From 847aea208848daede4f73b24561baf98d238952c Mon Sep 17 00:00:00 2001 From: Sanish Date: Fri, 14 Jan 2022 11:25:45 +0000 Subject: [PATCH] :sparkles: add new resolutionType ratioWithMinDimensions --- src/typings.ts | 7 ++++++- src/validation.ts | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/typings.ts b/src/typings.ts index 785820c..89be36e 100644 --- a/src/typings.ts +++ b/src/typings.ts @@ -48,4 +48,9 @@ export type ErrorsType = { resolution?: boolean; } | null; -export type ResolutionType = 'absolute' | 'less' | 'more' | 'ratio'; +export type ResolutionType = + | 'absolute' + | 'less' + | 'more' + | 'ratio' + | 'ratioWithMinDimensions'; diff --git a/src/validation.ts b/src/validation.ts index 6bf30d7..caeb2b3 100644 --- a/src/validation.ts +++ b/src/validation.ts @@ -31,6 +31,16 @@ export const isResolutionValid = ( return true; break; } + case 'ratioWithMinDimensions': { + const ratio = resolutionWidth / resolutionHeight; + if ( + image.width / image.height === ratio && + image.width >= resolutionWidth && + image.height >= resolutionHeight + ) + return true; + break; + } default: break; }