Created
July 16, 2014 20:08
-
-
Save heymichaelp/e916865a247db525f262 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var utensils = require('./lib/utensils'); | |
var Form = utensils.Form; | |
var Validator = utensils.Validator; | |
var Service = utensils.Service; | |
var AccountValidator = Validator.extend({ | |
email: function() { | |
return true; | |
}, | |
gender: function(resolve, reject) { | |
resolve(); | |
} | |
}); | |
var CreateAccount = Service.extend({ | |
argumentNames: ['account'], | |
procedure: [ | |
'saveToDatabase', | |
'sendWelcomeEmail' | |
], | |
saveToDatabase: function( resolve, reject ) { | |
resolve(); | |
}, | |
sendWelcomeEmail: function() { | |
return true; | |
} | |
}) | |
var MyForm = Form.extend({ | |
validator: AccountValidator, | |
persistor: CreateAccount, | |
}); | |
new MyForm({first: 'michael', last: 'phillips'}).process() | |
.then(function(){ console.log('done' ) }) | |
.fail(function( errors ){ console.log('fail' ) }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment