How do you reference other property values in JSON schema?

前端 未结 3 1271
感情败类
感情败类 2021-01-05 07:07

I have a JSON schema with 2 properties, minimumTolerance and maximumTolerance. I need to make sure that the value of maximumTolerance is not smaller than minimumTolerance &a

3条回答
  •  梦谈多话
    2021-01-05 07:44

    If you are using AJV You can do this using $data and relative JSON pointers. Example:

      low: {
        type: 'integer',
        maximum: {
          $data: '1/high',
        },
        exclusiveMaximum: true,
      },
    
      high: {
        type: 'integer',
        minimum: {
          $data: '1/low',
        },
        exclusiveMinimum: true,
      },
    

提交回复
热议问题