Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isValidDate does not check single date values #145

Open
joegasewicz opened this issue Jun 10, 2021 · 4 comments
Open

isValidDate does not check single date values #145

joegasewicz opened this issue Jun 10, 2021 · 4 comments
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@joegasewicz
Copy link
Owner

if (fromDate && toDate) {

I expect this function to work like this:

isValidDate({startDate: "2021-06-1"});
isValidDate({endDate: "2021-06-1"});
isValidDate({startDate: "2021-06-1", endDate: "2021-06-1"});
@joegasewicz joegasewicz added bug Something isn't working enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Jun 10, 2021
@rustmn
Copy link

rustmn commented Jun 10, 2021

I can do this.

By the way, this check and other like this will fail in the runtime and will lead to error because typescript check types only on compile / development stage -

if (!fieldValue) {

@joegasewicz
Copy link
Owner Author

@rustmn Please go ahead with this is issue #145, I will look into if (!fieldValue) { btw this is a value check / cohesion to a boolean , not a type check (typeof).
Thanks

@rustmn
Copy link

rustmn commented Jun 11, 2021

@joegasewicz ok, I'm about this -

export const isValidDate: IValidationVariable = customValidator((args: [string, string], fieldValue: Date, _) => {

You expect fieldValue to be a Date object, you check only if it's value is not null / undefined / false, and then interact with it as it were a Date object -

if(fieldValue > fromDate && fieldValue < toDate) {

Some users may pass an empty object and it will not work as expected, I'll fix it.

@joegasewicz
Copy link
Owner Author

@rustmn great , go ahead, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants