Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gaykey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Kio!
gaykey
Commits
1e1800fd
Commit
1e1800fd
authored
8 years ago
by
syuilo⭐️
Browse files
Options
Downloads
Patches
Plain Diff
Update it.ts
parent
42ed35bf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/api/it.ts
+24
-0
24 additions, 0 deletions
src/api/it.ts
with
24 additions
and
0 deletions
src/api/it.ts
+
24
−
0
View file @
1e1800fd
...
...
@@ -26,6 +26,30 @@
* const [val, err] = it(x).expect.string().required().qed();
*/
/**
* null と undefined の扱い
*
* 「値がnullまたはundefined」な状態を「値が空である」と表現しています。
* 値が空である場合、バリデータやその他の処理メソッドは呼ばれません。
*
* 内部的にはnullとundefinedを次のように区別しています:
* null ... 値が「無い」と明示されている
* undefined ... 値を指定していない
*
* 例えばアカウントのプロフィールを更新するAPIに次のデータを含むリクエストが来たとします:
* { name: 'Alice' }
* アカウントには本来、他にも birthday といったフィールドがありますが、
* このリクエストではそれに触れず、ただ単に name フィールドを更新することを要求しています。
* ここで、このリクエストにおける birthday フィールドは undefined なわけですが、
* それはnull(=birthdayを未設定にしたい)とは違うものです。
* undefined も null も区別しないとしたら、触れていないフィールドまでリセットされることになってしまいます。
* ですので、undefined と null は区別しています。
*
* 値が空であってほしくない場合は .require() を、
* 値を必ず指定しなければならない場合(値を「無し」に指定することは許可)は .notUndefined() を、
* 値の指定をしなくてもいいけど、する場合は「無し」は許可しない場合は .notNull() を使えます。
*/
import
*
as
mongo
from
'
mongodb
'
;
import
hasDuplicates
from
'
../common/has-duplicates
'
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment