koa-swagger-decorator icon indicating copy to clipboard operation
koa-swagger-decorator copied to clipboard

date format should check 'yyyy-MM-dd' as stated in OpenAPI definition

Open paoesco opened this issue 2 years ago • 0 comments

Hello,

It seems date and date-time formats are both treated as date-time in the validation, but date should accept date only values like 2022-01-01.

According to OpenAPI documentation:

An optional format modifier serves as a hint at the contents and format of the string. OpenAPI defines the following built-in string formats:
date – full-date notation as defined by [RFC 3339, section 5.6](https://tools.ietf.org/html/rfc3339#section-5.6), for example, 2017-07-21
date-time – the date-time notation as defined by [RFC 3339, section 5.6](https://tools.ietf.org/html/rfc3339#section-5.6), for example, 2017-07-21T17:32:28Z

Culprit is in check.ts

  if ((expect.format === 'date' || expect.format === 'date-time') && !validator.isRFC3339(val)) return { is: false };

Thanks

paoesco avatar Mar 31 '22 12:03 paoesco