Last active
August 29, 2015 14:08
-
-
Save sadjow/fa6d9f89e8d90465306c to your computer and use it in GitHub Desktop.
A simple example of makesure using CoffeeScript
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
validateUser = makesure -> | |
@permit "name email" # optional | |
@attrs("name email").isNot('empty').orSay "can't be empty" | |
userInput = | |
name: "" | |
description: "My description" | |
admin: true | |
# Validates a object, with an intrusive attribute. | |
validateUser userInput, (error, user) -> | |
# error == { | |
# error: { | |
# attrs: { | |
# name: { | |
# messages: { "empty": "can't be empty" } | |
# } | |
# } | |
# } | |
# } | |
# user == { | |
# name: '', | |
# description: 'My description' | |
# } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The parentesis in
makesure
are optionals 😆