sketch-hq/sketch-document

Incorrect usage of ExclusiveMinimum

raveclassic opened this issue · 4 comments

Hi,

Looks like gradient schema is incorrect according to JSON Schema 7 in the following lines: https://github.com/sketch-hq/sketch-file-format/blob/d61c8a2e3d81ecfe0890d39e1a48f2add77801cb/schema/objects/gradient.schema.yaml#L10-L13

exclusiveMinimum should be defined on numeric instances according to spec. Is it a bug or
some extension like #28?

Looks like there's another place where exlusiveMimimum is not aligned with JSON Schema 7:
https://github.com/sketch-hq/sketch-file-format/blob/d61c8a2e3d81ecfe0890d39e1a48f2add77801cb/schema/objects/border.schema.yaml#L10-L12
Should be:

thickness:
    type: number
    minimum: 0
    exclusiveMinimum: true

or

thickness:
    type: number
    exclusiveMinimum: false

Ah good catches, thanks. Will look into these.

@raveclassic For the first point you mention, in gradient.schema.yaml I think you're right - I should be using minItems to express a minimum length for the array. I don't think stops array can ever be empty so I'll set minItems to 1.

But I'm not sure about your point relating to border.schema.yaml ... reading about the usage of exclusiveMinimum here suggests that boolean values for exclusiveMinimum are part of JSON Schema 4. Using numerical values, are valid according to JSON Schema 7. Does that seem right to you?

@jedrichards

boolean values for exclusiveMinimum are part of JSON Schema 4. Using numerical values, are valid according to JSON Schema 7

Oups, sorry, you are right. I confused version 4 with 7. https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.2.5 says it's correct to use numeric values.