mac- / ratify

A Hapi plugin for validating the schema of path, query, request body, and response body params using JSON-schema
MIT License
71 stars 27 forks source link

Convert strings formatted as date-time to Date objects? #54

Open rolodato opened 7 years ago

rolodato commented 7 years ago

Hi @mac-, would you accept a PR to automatically convert strings defined with date-time formats to Date object? This is useful, for example, when saving Date objects to MongoDB - otherwise they are persisted as strings by default.

Current behavior is here: https://github.com/mac-/ratify/blob/9f3b09dc5c93d5d4597f683405df52196a5e8eee/lib/RouteSchemaManager.js#L107

Seems this would be a breaking change. The only other JSON schema string format that has an equivalent Node type is uri, which we might want to convert automatically as well. Let me know what you think.

Thanks!