javascript - How to verify that the timestamp send is in UTC in mongoose/Hapijs? -
i'm building application in node.js using hapi , database in mongodb using mongoose. have following message schema:
var schema = { : { type : schema.objectid, ref : 'user' }, content : { type : string, required : true }, group : { type : schema.objectid, ref : 'group' }, created : { type : number, default : date.now() } };
i want created
field in schema timestamp , in utc. client converts current timestamp utc timestamp , sends server. however, can't find possible way on server verify whether timestamp provided has been converted utc or not. there way impose validation in hapi/mongoose?
thanks in advance.
edit:
- changed type of
created
fieldnumber
since want storetimestamp
, not date string.
hapi allows have validate
property on each route. under hood uses joi validate schema provided in property payload, parameters, query string , headers: route configuration
using can validate created
field particular date format: date.format()
for example validate iso 8601 format:
validate: { payload: { created: joi.date().iso(); } }
Comments
Post a Comment