首页 > 解决方案 > How to create an integer, json-schema, validation rule that validates an integer is not equal to 0(zero)?

问题描述

I would like to validate an integer value (property) on not being 0(zero). Positive and negative integers are allowed, except 0.

标签: jsonschema

解决方案


You can use not enum: {"type":"integer", "not":{"enum":[0]}}.

Or not const with recent JSON Schema revision: {"type":"integer", "not":{"const":0}}


推荐阅读