Clojure Schema validation

Schema is a Clojure library for declarative data description and validation. Basically it will throw exception when data is not what it is supposed to be.

Couldn’t find by googling a way to enable date to be either existing or not known (null). So when I figured it out, I wanted to share solution with everybody. The example requires that the person has a name (String), but birthdate (Date) is not required.

1
2
3
4
5
6
7
8
9
(:require [schema.core :as s])
 
(defn person
  [name born]
  (s/validate s/Str name)
  (s/validate (s/either java.util.Date (s/pred nil?)) born)
  {:name name
   :born born
  })

Oh, and it is also possible to combine different types like Integers and Strings for enum validation:

1
2
3
4
5
6
7
8
9
(:require [schema.core :as s])
 
(defn person
  [name hands]
  (s/validate s/Str name)
  (s/validate (s/enum 1 2 "none") hands)
  {:name name
   :hands hands
  })

Obawangchicheng got finished?

Well, it didn’t. The project is insane, but still slowly progressing. Here is a collage of pictures (360 °) of current status of the project. Oh, I have my both children now roaming the region with me, as I turned the world into an inhouse server.

Just a reminder, that every block is mined first, and then placed by hand one by one.

HearthStone – virtual card game

HearthStone is the new game Blizzard is working on hard. A virtual collectible card game based on different classes and skills of Azeroth heros, with possibility to use real money for faster advancement int the game.

And as being a closed beta tester, I say it is turning into a fine game indeed. It has truly a World of Warcraft feel in it: graphics, sounds, and atmosphere, without dragging the MMORPG parts into the game at all.

For a casual player, it feels best played against your real life friends, than random world players. It remains to be seen will there wether be any crossover with the parent game like: pets, vanity items, even titles – or not?