Last active
August 29, 2015 14:16
-
-
Save Sivli-Embir/d37d25282c1126d0e952 to your computer and use it in GitHub Desktop.
This file contains 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
<template name='form'> | |
<input name='email' value={{email}}> | |
{{#with validate 'email'}} | |
{{message}} | |
{{/with}} | |
</template> |
This file contains 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
EmailForm = new ShadowModel({ | |
collection: new Mongo.Collection('example'), | |
fields: { //basically a transform + schema for instances | |
email: function (value) { | |
var email = someEmailValidator(value) //readme shortcut -_^ | |
if (email) { | |
if (email == 'gmail') { | |
return this.valid('is a Gmail email') | |
} else if (email == 'apple') { | |
return this.valid('is an Apple email') | |
} else { //and so on | |
return this.valid('is email') | |
} | |
} else { | |
return this.invalid('must be an email') //you would want to be more descriptive... | |
} | |
}, | |
... | |
} | |
} | |
Template.form.helpers({ | |
data: function () { | |
return EmailForm.new() | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment