File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments