### Validation函數
在繼續介紹下一個引用類型之前,下面是一個validation函數的例子,他驗證所有賦給Ref的值是數字。
```
; Note the use of the :validator directive when creating the Ref
; to assign a validation function which is integer? in this case.
(def my-ref (ref 0 :validator integer?))
(try
(dosync
(ref-set my-ref 1) ; works
; The next line doesn't work, so the transaction is rolled back
; and the previous change isn't committed.
(ref-set my-ref "foo"))
(catch IllegalStateException e
; do nothing
))
(println "my-ref =" @my-ref) ; due to validation failure -> 0
```