October 11, 2011 at 10:41am

isUnique validation with Lithium

This validation rule allows you to validate unique values of any field in any model.

Mariano Iglesias posted an updated version of the validator rule, which supports existing records. Here is the updated version.

<?php
/**
 * isUnique validator for any model. Example usage in model:
 *
 * public $validates = array(
 *     'email' => array('isUnique', 'message' => 'This email is already used')
 * );
 */
Validator::add('isUnique', function ($value, $format, $options) {
    $conditions = array($options['field'] => $value);
    foreach((array) $options['model']::meta('key') as $field) {
        if (!empty($options['values'][$field])) {
            $conditions[$field] = array('!=' => $options['values'][$field]);
        }
    }
    $fields = $options['field'];
    return is_null($options['model']::find('first', compact('fields', 'conditions')));
});
?>

More about validation with Lithium

September 13, 2011 at 9:16am

Design is how it works

— Steve Jobs

July 25, 2011 at 1:48pm

Enable SSH Agent (key) forwarding on Mac OS Lion

It looks like in some occasions ssh agent (key) forwarding doesn’t work anymore after upgrading to Mac OS Lion.

Gladly the solution is easy, you just need to run the following command in your Terminal and reboot after that.

ssh-add

This adds your identity back to the authentication agent again.

June 9, 2011 at 11:47am

CloudProvider’s Cloud Portal almost ready to go live!

June 8, 2011 at 5:14pm

Preview of the first iPad app I&#8217;m working on.

Preview of the first iPad app I’m working on.

4:31pm

Op maat gemaakte apps voor MKB'ers met bestaande online software →

“Komende jaren zal mijn werk steeds minder uit het zelf ontwikkelen van online software bestaan, maar meer uit het koppelen van bestaande Software as a Service (SaaS)-oplossingen en het in een logisch geheel gieten.”

May 13, 2011 at 1:12pm

Downgrading a PECL module

Downgrading a PECL module is quite easy.

pecl install -f module-x.x.x

-f makes sure the current installed version of the module will be overwritten.

(Source: lornajane.net)