You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, when I try to validate with convert: true the millisecond value is converted to ISO date string. Additionally, when passing convert: false the validation fails completely.
Thanks.
varjoi=require('joi');constschema=joi.object({create_dt: joi.date().timestamp()});// converts to ISO date string???varresult1=joi.validate({create_dt: 1465599344356},schema);console.log('Result 1:')console.log(JSON.stringify(result1));console.log('\n')// fails validation ???varresult2=joi.validate({create_dt: 1465599344356},schema,{convert: false});console.log('Result 2: ')console.log(JSON.stringify(result2))
Which result you had ?
Result 1:
{"error":null,"value":{"create_dt":"2016-06-10T22:55:44.356Z"}}
Result 2:
{"error":{"isJoi":true,"name":"ValidationError","details":[{"message":"\"create_dt\" must be a valid timestamp or number of milliseconds","path":"create_dt","type":"date.timestamp.javascript","context":{"key":"create_dt"}}],"_object":{"create_dt":1465599344356}},"value":{"create_dt":1465599344356}}
What did you expect ?
The text was updated successfully, but these errors were encountered:
{"error":{"isJoi":true,"name":"ValidationError","details":[{"message":"\"create_dt\" must be a valid timestamp or number of milliseconds","path":"create_dt","type":"date.timestamp.javascript","context":{"key":"create_dt"}}],"_object":{"create_dt":1465599344356}},"value":{"create_dt":1465599344356}}
Thanks for clarifying, this library has a lot of promise!
Context
What are you trying to achieve or the steps to reproduce ?
According to the documentation here: https://github.com/hapijs/joi/blob/v9.0.0-3/API.md#datetimestamptype; a millisecond value should pass validation for joi.date().timestamp()
However, when I try to validate with
convert: true
the millisecond value is converted to ISO date string. Additionally, when passingconvert: false
the validation fails completely.Thanks.
Which result you had ?
What did you expect ?
The text was updated successfully, but these errors were encountered: