Insert validation schema for one field based on another field

Hi everyone.
I have a structure like below which I want to validate according to what I will explain to you later.

router.post(
    {
      path: `${PLUGIN_API_PATH}/add`,
      validate: {
        body: schema.object({
          name: schema.string({ minLength: 1 }),
          description: schema.nullable(schema.string()),
          type: schema.oneOf([schema.literal('file'), schema.literal('link')]),
          data: schema.string({ minLength: 1 }),
          url: schema.string({ minLength: 1 }),
          format: schema.string({ minLength: 1 }),
          method: schema.string({ minLength: 1 }),
          authorization: schema.string({ minLength: 1 }),
          query: schema.string({ minLength: 1 }),
        }),
      },
    },
    async (context, request, response) => {
      .........
    }
  );

I want to bet based on the type field for data, url, etc. fields according to what I wrote.

router.post(
    {
      path: `${PLUGIN_API_PATH}/add`,
      validate: {
        body: schema.object({
          name: schema.string({ minLength: 1 }),
          description: schema.nullable(schema.string()),
          type: schema.oneOf([schema.literal('file'), schema.literal('link')]),
          data: if(type === 'file') ? schema.string({ minLength: 1 }) : schema.nullable(schema.string()),
          url: if(type === 'link') ? schema.string({ minLength: 1 }) : schema.nullable(schema.string()),
          format: if(type === 'link') ? schema.string({ minLength: 1 }) : schema.nullable(schema.string()),
          method: if(type === 'link') ? schema.string({ minLength: 1 }) : schema.nullable(schema.string()),
          authorization: if(type === 'link') ? schema.string({ minLength: 1 }) : schema.nullable(schema.string()),
          query: if(type === 'link') ? schema.string({ minLength: 1 }) : schema.nullable(schema.string()),
        }),
      },
    },
    async (context, request, response) => {
     ......
    }
  );

Basically, I want to validate one or more other fields based on the selected value for another field.

Is it possible?
Please guide me how to do this.

Thanks in advance.