Giter Club home page Giter Club logo

Comments (5)

rnestler avatar rnestler commented on August 21, 2024

Maybe we should make the location required again, but allow omitting all fields?

I don't think this provides much value. What's the purpose of an empty object?

Alternatively, we could keep location as optional, but make location.lat and location.lon optional as well. (Potentially with some rules to say that if one of them is defined, the other one must be defined as well.)

I'd like that.

This question is a release blocker for v15.

I don't think it should really be a blocker.

from schema.

dbrgn avatar dbrgn commented on August 21, 2024

I don't think this provides much value. What's the purpose of an empty object?

The empty object isn't the goal in itself, but it would be an alternative form of indicating that a space has no location.

The suggestion with a required "location" would mainly be that there aren't two ways to communicate the same thing. If the location can be omitted, and lat/lon are optional as well, then these two variants are equivalent in meaning:

{
  "location": {}, // Legal, because lat/lon are optional
}
{
  // Omit location completely
}

With the discussion about null potentially being an allowed value, there would even be a third way to indicate the same thing (although we don't currently allow null anywhere in the v15 draft):

{
  "location": null,
}

I generally prefer to have one right (canonical) way to represent something.

Keep in mind that in v15 we're explicitly making the location key optional. The first suggestion would be to instead make the lat/lon fields optional. That's also why I marked it as release blocker, because the discussion is about potentially reverting a decision we did in the current v15 draft. (And such things are easier before the release.)

from schema.

rnestler avatar rnestler commented on August 21, 2024

My favored solution would be to have location optional but require that if it is provided that at least one subkey must be provided (so making "location": {} illegal).

from schema.

dbrgn avatar dbrgn commented on August 21, 2024

My favored solution would be to have location optional but require that if it is provided that at least one subkey must be provided (so making "location": {} illegal).

Can this be easily implemented? Sounds like quite complex validation logic to me, that probably not every consumer of the JSON schema will implement 🙂

But to keep things simple, we can simply make both lat/lon optional and keep the location key optional as well (because I also think that an empty object is a bit ugly). The vast majority of spaces will have a location anyways.

from schema.

rnestler avatar rnestler commented on August 21, 2024

I'd suggest to leave it as is for v15 (optional location field, but if it is present have at least lat/lon) to not block the release.

But to keep things simple, we can simply make both lat/lon optional and keep the location key optional as well (because I also think that an empty object is a bit ugly). The vast majority of spaces will have a location anyways.

This can then be implemented in a v16 and we could add validation that if lat is present also lon is present or similar (should be doable with anyOf).

from schema.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.