Skip to content

Instantly share code, notes, and snippets.

@cddr
Created March 23, 2013 15:15
Show Gist options
  • Save cddr/5228055 to your computer and use it in GitHub Desktop.
Save cddr/5228055 to your computer and use it in GitHub Desktop.
Common Lisp validation syntax
(defclass venue (validatable)
((zip :col-type string :initarg :zip :accessor zip)
(phone :col-type string :initarg :phone :accessor phone)
(website :col-type (or db-null string) :initarg :website :accessor website))
(:metaclass pomo:dao-class)
(:keys id))
(defvalidators venue ()
(website (start-with "https://"))
(phone (match "(\\d\\d\\d)-\\d\\d\\d-\\d\\d\\d"))
(zip (match "\\d\\d\\d\\d\\d")))
(valid? (make-instance 'venue))
=> ((WEBSITE "NIL doesn't START-WITH (https://)")
(PHONE "NIL doesn't MATCH ((ddd)-ddd-ddd)") (ZIP "NIL doesn't MATCH (ddddd)"))
@ahmad05
Copy link

ahmad05 commented Mar 23, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment