-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat required config #48
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #48 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 1 1
Lines 162 164 +2
Branches 56 57 +1
=====================================
+ Hits 162 164 +2
Continue to review full report at Codecov.
|
The condition is when having a create and edit common interface , I may code like this: const schema = {
userId: {
type: 'int'
},
title: {
required: false,
type: 'string',
},
brief: {
required: false,
type: 'string',
},
content: {
required: false,
type: 'string',
},
xxx1: {
required: false,
type: 'string',
},
...
}
ctx.validate(schema, myParams); |
index.js
Outdated
@@ -33,6 +33,9 @@ class Parameter { | |||
if (opts.validateRoot) { | |||
this.validateRoot = true; | |||
} | |||
this.defaultRequired = opts.defaultRequired !== undefined ? | |||
opts.defaultRequired : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.defaultRequired = opts.defaultRequired !== false;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx for cr ! ~
index.js
Outdated
if (rule.required !== false) { | ||
var required = rule.required !== undefined ? | ||
rule.required : | ||
this.defaultRequired; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
放一行吧,这样缩进有点奇怪
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯嗯,已修改。 839d425
698d819
to
85e257b
Compare
docs: options.defaultRequired
rebase ? |
No description provided.