Comments (3)
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.
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.
Finally solved it in latest release 1.9.10
- also added runtime mode
configuration
from schema-to-yup.
Related Issues (20)
- Get all properties under a schema HOT 1
- Custom error messages not having any effect HOT 4
- Custom message for type error HOT 18
- which version of yup does schema-to-yup support HOT 3
- "isNullable" is not working for Object type HOT 3
- Update yup to the newest 1.x version HOT 2
- Previously working required message, drops when combining refValueFor
- Previously working required message, drops when combining refValueFor HOT 1
- `ensure` on array does not work/missing example HOT 2
- Tests fail on fresh clone and install of dependencies HOT 3
- There is no regexp function that validate using a pattern which covers Unicode
- `TypeError: Cannot add property required, object is not extensible` on Node server using `esm` HOT 1
- Latest daft version `2020-12` is not supported HOT 2
- Question : why nullable and not type: ["null", ...] ? HOT 7
- Missing support for 'integer' HOT 11
- Multiple when causing Cyclic errors HOT 4
- TypeError: Invalid attempt to spread non-iterable instance.
- Custom 'required' error message doesn't work on fields with 'refValueFor' prop. HOT 1
- Unable to define type objects whichs default may be null
- yup.test
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from schema-to-yup.