Giter Site home page Giter Site logo

Comments (4)

SamSedivy avatar SamSedivy commented on May 29, 2024

Is it possible to remove the validation for fields with format = "date" ?

from json-editor.

schmunk42 avatar schmunk42 commented on May 29, 2024

Sounds tricky...

What's possible is to define string,null for the property, but this does not exactly do what you want.

{
  "title": "json schema example",
  "type": "object",
  "properties": {
    "example": {
      "type": [
        "string",
        "null"
      ],
      "format": "date",
      "description": "This is an example schema.",
      "default": ""
    }
  }
}

Or you could use show_opt_in, but that removes the property completely if not set.

@SamSedivy Do you validate the data on the server also? Is an empty string valid?

@germanbisurgi any ideas? Is it possible to override the validation?

from json-editor.

germanbisurgi avatar germanbisurgi commented on May 29, 2024

The problem is that json-editor shouldn't use format keyword for validation per default. More on that here.
A couple of solutions that came in mind:

With pattern

{
  "type": "string",
  "description": "Format 'YYYY-MM-DD', or empty.",
  "pattern": "^(|\\d{4}-\\d{2}-\\d{2})$"
}

with oneOf

{
  "type": "string",
  "description": "Format 'YYYY-MM-DD', or empty.",
  "oneOf": [
    {
      "title": "Date Format",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    {
      "title": "Empty String",
      "pattern": "^$"
    }
  ]
}

from json-editor.

matthiask avatar matthiask commented on May 29, 2024

This has bitten me as well.

Previously, this schema has worked fine:

    schema={
        "type": "object",
        "properties": {
            "title": {"type": "string"},
            "issues": {
                "type": "array",
                "format": "table",
                "minItems": 1,
                "items": {
                    "type": "object",
                    "properties": {
                        "number": {
                            "type": "string",
                        },
                        "published_on": {
                            "type": "string",
                            "format": "date",
                        },
                    },
                },
            },
        },
    }

Now it already fails when initializing the editor for a new object. Changing minItems to zero allows the initialization to proceed. The oneOf thing isn't an option really since an empty string isn't valid but there's no way to even enter any data. The exact error is t.errmsg is undefined in the addInputError handler, but I'm not sure if that helps.

EDIT: The big problem is that the initialization fails and the je-not-loaded isn't removed; pointer-events:none makes it impossible to select the fields to start adding valid data.

from json-editor.

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.