Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 02e8dddc
authored
May 19, 2013
by
Bart Nagel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test for skipping validations when value is null and allowNull is true
1 parent
4bca6178
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
spec/dao.validations.spec.js
spec/dao.validations.spec.js
View file @
02e8ddd
...
@@ -282,5 +282,29 @@ describe(Helpers.getTestDialectTeaser("DAO"), function() {
...
@@ -282,5 +282,29 @@ describe(Helpers.getTestDialectTeaser("DAO"), function() {
var
successfulUser
=
User
.
build
({
name
:
"2"
})
var
successfulUser
=
User
.
build
({
name
:
"2"
})
expect
(
successfulUser
.
validate
()).
toBeNull
()
expect
(
successfulUser
.
validate
()).
toBeNull
()
})
})
it
(
'skips other validations if allowNull is true and the value is null'
,
function
()
{
var
User
=
this
.
sequelize
.
define
(
'User'
+
Math
.
random
(),
{
age
:
{
type
:
Sequelize
.
INTEGER
,
allowNull
:
true
,
validate
:
{
min
:
{
args
:
0
,
msg
:
'must be positive'
}
}
}
})
var
failingUser
=
User
.
build
({
age
:
-
1
})
,
errors
=
failingUser
.
validate
()
expect
(
errors
).
not
.
toBeNull
(
null
)
expect
(
errors
).
toEqual
({
age
:
[
'must be positive'
]
})
var
successfulUser1
=
User
.
build
({
age
:
null
})
expect
(
successfulUser1
.
validate
()).
toBeNull
()
var
successfulUser2
=
User
.
build
({
age
:
1
})
expect
(
successfulUser2
.
validate
()).
toBeNull
()
})
})
})
})
})
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment