GithubHelp home page GithubHelp logo

Comments (1)

MFSY avatar MFSY commented on June 16, 2024

Hi,
I would suggest the following strategy to start with media type validation:

  • Users should be allowed to use string as media type value like:
"mediaType":"application/json"

This corresponds to a widely adopted way of using media types.

  • The first step for validation would be to check that the providing string match IANA media type structure. The media type pattern can be seen in nexus/core/distribution and in nexus/core/mediatype schemas.

  • The second step would be to check that a provided media type is in a given list. Any schema can define a list of accepted values for a property. You can extends the distribution schema in you custom entity schema like this:

{

"shapes": [
    {
      "@id": "this:DistributionShape",
      "@type": "sh:NodeShape",
      "and": [
        {
          "node":"{{base}}/schemas/nexus/core/distribution/v0.1.0/shapes/DistributionShape"
        },
        {
          "property": [
            {
              "path": "schema:mediaType",
              "in": ["application/pdf","application/json"]
            }
          ]
        }
      ]
    }
  ]
}

But this strategy comes with downsides:

  • every time a new media type is added than a new schema version is needed.
  • regex based validation is slow.

We can improve this strategy later by relying on types for media types.

from nexus-bbp-domains.

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.