class-validator icon indicating copy to clipboard operation
class-validator copied to clipboard

fix: MinDate & MaxDate constraint message unclear

Open EmirBoyaci opened this issue 3 years ago • 4 comments

Description

With the version of [email protected], it allows us to pass dynamic Date to the MinDate and MaxDate (with PR https://github.com/typestack/class-validator/pull/1692). However, when I tried to use MinDate with a past date it throws an error which is unclear or unreadable. I think it is because while building the message, buildMessage function is not invoking the function which returns date.

Minimal code-snippet showcasing the problem

@MinDate(() => new Date())
@MaxDate(() => new Date())

Expected behavior

Replace () => new Date() with it's invoked version.

Actual behavior

image

EmirBoyaci avatar Dec 25 '22 10:12 EmirBoyaci

Maybe this file can be referenced since it is also using function as a parameter.

EmirBoyaci avatar Dec 25 '22 10:12 EmirBoyaci

It would be nice to see the actual date in the error message. Do you want to take a stab at implementing this, @EmirBoyaci?

braaar avatar Jan 04 '23 13:01 braaar

It would be nice to see the actual date in the error message. Do you want to take a stab at implementing this, @EmirBoyaci?

Hi, I did some changes and currently it is working. You may check whenever you've free time.

EmirBoyaci avatar Jan 04 '23 14:01 EmirBoyaci

Any news about this issue? I'm currently using v0.14.1 and this behavior still exists.

DocAmaroo avatar Nov 19 '25 13:11 DocAmaroo