Giter Site home page Giter Site logo

guardjs's Introduction

LinkedIn Blog

๐Ÿ‘จโ€๐Ÿ’ป About Me:

15 years as Software Engineer and Solutions Architect, I also have a strong experience in Leadership, Product Development and Project Management. Interested in: software architecture and development, excelent communication, people, personal development, playing guitar and travelling :)


๐Ÿ› ๏ธ Languages and Tools:

My Skills


๐Ÿ”ฅ My Stats:

GitHub Streak

Top Langs


โœ๏ธ Blog Posts:

guardjs's People

Contributors

phillippelevidad avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

guardjs's Issues

Edge case in isoDateTime (February 30th)

Hi,

not using guardjs (yet, perhaps, historically using Joi within the project) but found a possible issue while writing my own guards, validating isoDateTime strings.

add ["2022-02-30T00:00:00.000Z", THROW], to "isoDateTime" cases in Guard.spec.ts

run npm test

Expected result: โœ”๏ธ isoDateTime
Actual result: โŒ isoDateTime


Why:

new Date('2022-02-30T00:00:00.000Z').toISOString()
// '2022-03-02T00:00:00.000Z'

Perhaps another peculiarity of Javascript's Date(), my PostgreSQL agrees with me, and I'm pretty sure other DBs would as well, February 30th 2022 is not a valid date, hence that should not be a valid ISO string.

select date_part('day', '2022-02-30T00:00:00.000Z'::timestamp);
-- Query 1: ERROR:  date/time field value out of range: "2022-02-30T00:00:00.000Z" ...

whereas

select date_part('day', '2022-02-28T00:00:00.000Z'::timestamp);
-- 28

Since I'm already using moment.js in the project as well, I went the route of using that.

moment('2022-02-30T00:00:00.000Z', 'YYYY-MM-DDTHH:mm:ss.SSSZ').isValid()
// false

However, since you support other tz offsets than just Zulu, the solution would not be as trivial as using return !isNaN(date.getTime()) && date.toISOString() === val;

Cheers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.