-
Notifications
You must be signed in to change notification settings - Fork 2
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
[#1] Rockstar Validation #1
base: master
Are you sure you want to change the base?
Conversation
function Validate(options) { | ||
return { | ||
isValid: isValid(options), | ||
message: getMessage(options) |
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.
When calling getMessage you are essentially calling the validation method (be it either nameRequired, instrumentRequired or any other method) a second time (it was already called in isValid). Try to come up with a design which runs the validation rules only once.
We also need composite rules, rules made out of multiple rules. |
} | ||
|
||
function instrumentRequired(options) { | ||
return _.isString(options.guitar) || _.isString(options.drums); |
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 seems to be the same code as in nameRequired
except with a different property name. If you were to rename nameRequired
to stringRequired
and it would receive the attribute as a parameter you would have no more duplication.
Something is not right yet, for me functional means that everything is a function, something like this: // Use a Promise-based library to do IO.
var http = require("q-io/http")
,noop = new Promise(()=>{})
,prepare =
(str)=> http.read('http://www.example.com/' + str)
.then((res)=> res.body.toString())
// the 'then' is equal to the '>>'
,makeQuery =
(strs)=> strs.map((str)=> prepare(str))
,doQuery =
(qrys)=> qrys.reduce((results, qry)=> results.then(qry), noop)
,stmts = [ "articles/FunctionalJavaScript"
, "blob/c745ef73-ece9-46da-8f66-ebes574789b1"
, "books/language/Haskell"
]
,main = doQuery(makeQuery(stmts)); |
No description provided.