Coder Social home page Coder Social logo

Comments (3)

kristianmandrup avatar kristianmandrup commented on August 17, 2024

You must explicitly set notRequired: true to make it work. In yup, any type constraint automatically tests if the value is a valid instance of that type. See if you can pre-process your JSON schema to add notRequired to any property constraints that are not require: true or in the required list of properties.

Been trying for the past 5 hours to hack it to automatically do it... The whole infrastructure needs a rewrite, which I have been busy working on in the constraint-builder branch.

from schema-to-yup.

kristianmandrup avatar kristianmandrup commented on August 17, 2024

I think another option would be to change this part in Mixed

class YupMixed extends Base {
  constructor(opts = {}) {
    super(opts.config);
    let { schema, key, value, config } = opts;
    config = config || {};
    schema = schema || {};
    this.validateOnCreate(key, value, opts);
    this.yup = yup;
    this.key = key;
    this.schema = schema;
    this.properties = schema.properties || {};

    console.log({ value });
    this.value = value;

To use a set value(value) which checks if required: true in the value and if not, inserts notRequired: true

from schema-to-yup.

kristianmandrup avatar kristianmandrup commented on August 17, 2024

Finally solved it in latest release 1.9.10 - also added runtime mode configuration

from schema-to-yup.

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.