Comments (4)
I will add a test for it now and see if I can fix it ;)
from schema-to-yup.
If you look at types/mixed.js
you can see it references this.constraints.enum
There are string tests for oneOf
and notOneOf
. The use of enum
should just be an alias.
oneOf() {
let value =
this.constraints.enum || this.constraints.oneOf || this.constraints.anyOf;
if (this.isNothing(value)) return this;
value = Array.isArray(value) ? value : [value];
return this.addConstraint("oneOf", { value, errName: "enum" });
}
notOneOf() {
const { not, notOneOf } = this.constraints;
let value = notOneOf || (not && (not.enum || not.oneOf));
value = Array.isArray(value) ? value : [value];
return this.addConstraint("notOneOf", { value });
}
As you can see, String just extends Mixed
class YupString extends YupMixed {
constructor(obj) {
super(obj);
this.type = "string";
this.base = this.yup.string();
}
static create(obj) {
return new YupString(obj);
}
convert() {
// generic constraint building, including oneOf (enum) etc
super.convert();
// ... string specific constraint building
}
// ...
}
from schema-to-yup.
Pls check my latest commit to master (better string testing) and debug from there. I see some tests are currently broken. Sorry.
from schema-to-yup.
Fixed this issue and all string related issues in latest release :)
from schema-to-yup.
Related Issues (20)
- RefValue documentation error HOT 1
- JSON schemas with an array in `type` result in an error HOT 5
- Required Logic broken? HOT 8
- strict uppercase doesn't work with minLength and maxLength HOT 7
- handling trailing and leading spaces, `trim` doesn't work ? HOT 1
- 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
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.