rules = array( "name" => array("rules" => array("required", "length[1,32]"), "callbacks" => array(array($this, "valid_name"))), "flat_rate" => array("rules" => array("required", "decimal")), "per_item" => array("rules" => array("required"))); } parent::validate($array); } /** * Validate the item name. It can't conflict with other names, can't contain slashes or * trailing periods. */ public function valid_name(Validation $v, $field) { $postage_band = ORM::factory("postage_band")->where("name", "=", $this->name)->find(); if ($postage_band->loaded() && $postage_band->id != $this->id) { $v->add_error("name", "in_use"); } } }