@@ -46,6 +46,13 @@ abstract class Ardent extends Model {
4646 public static $ customMessages = array ();
4747
4848 /**
49+ * The array of custom attributes.
50+ *
51+ * @var array
52+ */
53+ public static $ customAttributes = array ();
54+
55+ /**
4956 * The validator object in case you need it externally (say, for a form builder).
5057 *
5158 * @see getValidator()
@@ -513,26 +520,28 @@ public static function configureAsExternal(array $connection, $lang = 'en') {
513520 * @param $data
514521 * @param $rules
515522 * @param $customMessages
523+ * @param $customAttributes
516524 * @return \Illuminate\Validation\Validator
517525 * @see Ardent::$externalValidator
518526 */
519- protected static function makeValidator ($ data , $ rules , $ customMessages ) {
527+ protected static function makeValidator ($ data , $ rules , $ customMessages, $ customAttributes ) {
520528 if (self ::$ externalValidator ) {
521- return self ::$ validationFactory ->make ($ data , $ rules , $ customMessages );
529+ return self ::$ validationFactory ->make ($ data , $ rules , $ customMessages, $ customAttributes );
522530 } else {
523- return Validator::make ($ data , $ rules , $ customMessages );
531+ return Validator::make ($ data , $ rules , $ customMessages, $ customAttributes );
524532 }
525533 }
526534
527535 /**
528536 * Validate the model instance
529537 *
530- * @param array $rules Validation rules
531- * @param array $customMessages Custom error messages
538+ * @param array $rules Validation rules
539+ * @param array $customMessages Custom error messages
540+ * @param array $customAttributes Custom attributes
532541 * @return bool
533542 * @throws InvalidModelException
534543 */
535- public function validate (array $ rules = array (), array $ customMessages = array ()) {
544+ public function validate (array $ rules = array (), array $ customMessages = array (), array $ customAttributes = array () ) {
536545 if ($ this ->fireModelEvent ('validating ' ) === false ) {
537546 if ($ this ->throwOnValidation ) {
538547 throw new InvalidModelException ($ this );
@@ -553,6 +562,7 @@ public function validate(array $rules = array(), array $customMessages = array()
553562 $ success = true ;
554563 } else {
555564 $ customMessages = (empty ($ customMessages ))? static ::$ customMessages : $ customMessages ;
565+ $ customAttributes = (empty ($ customAttributes ))? static ::$ customAttributes : $ customAttributes ;
556566
557567 if ($ this ->forceEntityHydrationFromInput || (empty ($ this ->attributes ) && $ this ->autoHydrateEntityFromInput )) {
558568 $ this ->fill (Input::all ());
@@ -561,7 +571,7 @@ public function validate(array $rules = array(), array $customMessages = array()
561571 $ data = $ this ->getAttributes (); // the data under validation
562572
563573 // perform validation
564- $ this ->validator = static ::makeValidator ($ data , $ rules , $ customMessages );
574+ $ this ->validator = static ::makeValidator ($ data , $ rules , $ customMessages, $ customAttributes );
565575 $ success = $ this ->validator ->passes ();
566576
567577 if ($ success ) {
0 commit comments