Skip to content

Commit 3239e93

Browse files
authored
Merge pull request #85 from OpenBuildings/jam-save-model-docblock
jam save exception docblock
2 parents e804768 + 6b8fbfb commit 3239e93

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

classes/Kohana/Jam/Model.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ public function update_fields($values, $value = NULL)
236236
*
237237
* @param bool|null $validate
238238
* @return $this
239+
* @throws Kohana_Exception
240+
* @throws Jam_Exception_Validation
239241
*/
240242
public function save($validate = NULL)
241243
{
@@ -246,9 +248,9 @@ public function save($validate = NULL)
246248
$key = $this->_original[$this->meta()->primary_key()];
247249

248250
// Run validation
249-
if ($validate !== FALSE)
251+
if ($validate !== FALSE && !$this->check())
250252
{
251-
$this->check_insist();
253+
throw new Jam_Exception_Validation('There was an error validating the :model: :errors', $this);
252254
}
253255

254256
$this->_is_saving = TRUE;

classes/Kohana/Jam/Validated.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,16 @@ public function check($force = FALSE)
345345
return $this->is_valid();
346346
}
347347

348+
/**
349+
* @return $this
350+
* @throws Jam_Exception_Validation
351+
*
352+
* @deprecated Since 0.5.24 Use try-catch around save() instead. This might be removed in future version.
353+
*/
348354
public function check_insist()
349355
{
356+
@trigger_error('check_insist() is deprecated and might be removed in future version.', E_USER_DEPRECATED);
357+
350358
if ( ! $this->check())
351359
throw new Jam_Exception_Validation('There was an error validating the :model: :errors', $this);
352360

0 commit comments

Comments
 (0)