class-validator#Validator TypeScript Examples

The following examples show how to use class-validator#Validator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ValidAndCurrentSSA.ts    From ADR-Gateway with MIT License 6 votes vote down vote up
ValidAndCurrentSSA = (ssa: string) => {
  if (! new Validator().isJWT(ssa) ) {
    throw `SSA is not a valid JWT`
  }

  let decoded = <any>JWT.decode(ssa,{complete:true});
  let diff = moment(decoded.payload.exp*1000).utc().diff(moment().utc(),'seconds');
  if (diff < 60) throw "The SSA is expiring too soon";
  return true;
}