Accessing Other Fields in Schema Transformations and Custom Errors

Hi, is it possible to get value of another fields in schema? for example, i want to use duration value in the transformation of token field and is it also possible to return custom error in addition to ParseError, for example error like InvalidTokenError ?
const schema = Schema.Struct({
  duration: Schema.DurationFromSelf,
  token: Schema.transformOrFail(
    Schema.Struct({..}),
    Schema.String,
    {
      strict: true,
      encode: (...) => { /* decrypt token and get the data or return error */ },
      decode: (...) => { /* encrypt token with 'duration' value and return the encrypted string or return error in case of any failure */ } 
  )
})
Was this page helpful?