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 c8c6687e
authored
May 24, 2013
by
Bart Nagel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move error on non-function model validation function from validate() to DAO factory
Also add a test for it
1 parent
05a8ac72
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
2 deletions
lib/dao-factory.js
lib/dao.js
spec/dao-factory.spec.js
lib/dao-factory.js
View file @
c8c6687
...
...
@@ -21,6 +21,12 @@ module.exports = (function() {
schemaDelimiter
:
''
},
options
||
{})
// error check options
Utils
.
_
.
each
(
options
.
validate
,
function
(
validator
,
validatorType
)
{
if
(
!
Utils
.
_
.
isFunction
(
validator
))
throw
new
Error
(
"Members of the validate option must be functions. Model: "
+
name
+
", error with validate member "
+
validatorType
)
})
this
.
name
=
name
if
(
!
this
.
options
.
tableName
)
{
this
.
tableName
=
this
.
options
.
freezeTableName
?
name
:
Utils
.
pluralize
(
name
)
...
...
lib/dao.js
View file @
c8c6687
...
...
@@ -271,8 +271,6 @@ module.exports = (function() {
// for each model validator for this DAO
Utils
.
_
.
each
(
self
.
__options
.
validate
,
function
(
validator
,
validatorType
)
{
if
(
!
Utils
.
_
.
isFunction
(
validator
))
throw
new
Error
(
"Invalid model validator function: "
+
validatorType
)
try
{
validator
.
apply
(
self
)
}
catch
(
err
)
{
...
...
spec/dao-factory.spec.js
View file @
c8c6687
...
...
@@ -70,6 +70,20 @@ describe(Helpers.getTestDialectTeaser("DAOFactory"), function() {
})
}.
bind
(
this
),
'Invalid DAO definition. Only one autoincrement field allowed.'
)
})
it
(
'throws an error if a custom model-wide validation is not a function'
,
function
()
{
Helpers
.
assertException
(
function
()
{
this
.
sequelize
.
define
(
'Foo'
,
{
field
:
{
type
:
Sequelize
.
INTEGER
}
},
{
validate
:
{
notFunction
:
33
}
})
}.
bind
(
this
),
'Members of the validate option must be functions. Model: Foo, error with validate member notFunction'
)
})
})
describe
(
'build'
,
function
()
{
...
...
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