Permalink
Browse files

added basic example to readme and split docs tasks

  • Loading branch information...
1 parent 017b953 commit 1a190b39be058c5e3e09cf0eff39fedb25917a41 @logaan committed Oct 14, 2013
Showing with 24 additions and 7 deletions.
  1. +11 −3 README.md
  2. +3 −0 script/docs/generate
  3. +5 −3 script/docs/{ → publish}
  4. +2 −1 src/vlad/validation_types.clj
  5. +3 −0 test/vlad/test/readme.clj
View
@@ -15,6 +15,17 @@ To use vlad add the following to your `project.clj` dependencies:
API Docs: <http://logaan.github.io/vlad/vlad.html>
+## Basics
+
+```clojure
+(ns vlad.test.readme
+ (:require [vlad :refer :all]))
+
+(validate (present [:age]) {:name "Logan"})
+; => [{:type :vlad.validations/present
+ :selector [:age]}]
+```
+
## Composition
Vlad lets you build complex validations through composition. `join` will return
@@ -23,9 +34,6 @@ once the first validation fails. This helps avoid overwhelming your users with
redundant error messages.
```clojure
-(ns vlad.test.readme
- (:require [vlad :refer :all]))
-
(def common
(join (present [:name])
(present [:email])))
View
@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+
+lein with-profile doc doc
@@ -1,10 +1,12 @@
#!/usr/bin/env bash
-lein with-profile doc doc
+VLAD_PATH=`pwd`
cd ~/hacking/jekyll/logaan.github.io/ && \
-rm -r vlad && \
-cp -R ~/hacking/clojure/vlad/doc vlad && \
+rm -r vlad
+
+cd ~/hacking/jekyll/logaan.github.io/ && \
+cp -R $VLAD_PATH/doc vlad && \
git add . && \
git commit -avm "updated vlad docs" && \
git push origin master
@@ -4,7 +4,8 @@
(defprotocol Validation
"The core of vlad is the `Validation` protocol. It simply requires that your
validation type knows how to run against some data. Implementations of
- `validate` should return a sequence of errors as strings."
+ `validate` should return a sequence of errors. An error may be anything but
+ is generally of the form `{:type ::something :some-extra-data 123}`."
(validate [self data]))
(defn valid
@@ -2,6 +2,9 @@
(:require [vlad :refer :all]
[midje.sweet :as midje]))
+; Basics
+(validate (present [:age]) {:name "Logan"})
+
(def common
(join (present [:name])
(present [:email])))

0 comments on commit 1a190b3

Please sign in to comment.