From 8ac1128e98d930ca34c6e6cd652961fa77653eaf Mon Sep 17 00:00:00 2001 From: Igor Santos Date: Thu, 26 Dec 2013 00:54:05 -0200 Subject: [PATCH] Including a validateUniques method, just like we currently have updateUniques. closes #140 --- src/LaravelBook/Ardent/Ardent.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/LaravelBook/Ardent/Ardent.php b/src/LaravelBook/Ardent/Ardent.php index 2efee12..271f543 100644 --- a/src/LaravelBook/Ardent/Ardent.php +++ b/src/LaravelBook/Ardent/Ardent.php @@ -828,6 +828,19 @@ public function updateUniques(array $rules = array(), return $this->save($rules, $customMessages, $options, $beforeSave, $afterSave); } + /** + * Validates a model with unique rules properly treated. + * + * @param array $rules Validation rules + * @param array $customMessages Custom error messages + * @return bool + * @see Ardent::validate() + */ + public function validateUniques(array $rules = array(), array $customMessages = array()) { + $rules = $this->buildUniqueExclusionRules($rules); + return $this->validate($rules, $customMessages); + } + /** * Find a model by its primary key. * If {@link $throwOnFind} is set, will use {@link findOrFail} internally.