Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

OvidiuBan
Copy link
Contributor

No description provided.

function Validate(options) {
return {
isValid: isValid(options),
message: getMessage(options)

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.

@alexandru-calinoiu
Copy link
Member

We also need composite rules, rules made out of multiple rules.

}

function instrumentRequired(options) {
return _.isString(options.guitar) || _.isString(options.drums);

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.

@alexandru-calinoiu
Copy link
Member

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));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants