So this code throws up a "Parse error: syntax error, unexpected 'function' (T_FUNCTION)"
class User
{
public static $mapping = array(
'username' => array(
'type' => 'string',
'length' => 32,
'unique' => true,
'nullable' => function() {
// Some logic to determine value.
}
)
);
}