/**    * Determine if it's a necessary presence validation.    *    * This is to avoid possible database type comparison errors.    *    * @param  string  $rule    * @param  string  $attribute    * @return bool    */   protected function hasNotFailedPreviousRuleIfPresenceRule($rule, $attribute)   {//this function name it is to long    //but can tell all about this function action    // determine it is has not failed previousRule if Presence Rule       return in_array($rule, ['Unique', 'Exists'])                       ? ! $this->messages->has($attribute) : true;    // if this rule is unique or exists, we need determine this attribute other wo just return it it ok!   }// determine if it is necessary presence validation   /**    * Add a failed rule and error message to the collection.    *    * @param  string  $attribute    * @param  string  $rule    * @param  array   $parameters    * @return void    */   protected function addFailure($attribute, $rule, $parameters)   {       $this->addError($attribute, $rule, $parameters);//add Error message       $this->failedRules[$attribute][$rule] = $parameters;// insert this parameters into this failed Rules   }// add a failed rule and error message into this collection   /**    * Add an error message to the validator's collection of messages.    *    * @param  string  $attribute    * @param  string  $rule    * @param  array   $parameters    * @return void    */   protected function addError($attribute, $rule, $parameters)   {       $message = $this->getMessage($attribute, $rule);//first ,get all message about this rule       $message = $this->doReplacements($message, $attribute, $rule, $parameters);// change this message into this right format message       $this->messages->add($attribute, $message);// add it to this attribute   }// this is a small wrap about addFailed rule   /**    * "Validate" optional attributes.    *    * Always returns true, just lets us put sometimes in rules.    *    * @return bool    */   protected function validateSometimes()   {       return true;   }// Validate optional attributes.// return true;   /**    * "Break" on first validation fail.    *    * Always returns true, just lets us put "bail" in rules.    *    * @return bool    */   protected function validateBail()   {       return true;   }// just return ok, in this break type   /**    * Stop on error if "bail" rule is assigned and attribute has a message.    *    * @param  string  $attribute    * @return bool    */   protected function shouldStopValidating($attribute)   {       if (! $this->hasRule($attribute, ['Bail'])) {           return false;       }// no Bail switch no true,just return false,       return $this->messages->has($attribute);// if has it,just return this message.   }// determine this Bail messages   /**    * Validate that a required attribute exists.    *    * @param  string  $attribute    * @param  mixed   $value    * @return bool    */   protected function validateRequired($attribute, $value)   {       if (is_null($value)) {// no $value no ture           return false;       } elseif (is_string($value) && trim($value) === '') {           return false;// a null string just return false       } elseif ((is_array($value) || $value instanceof Countable) && count($value) < 1) {           return false;// array or a structural and no value in this structural       } elseif ($value instanceof File) {// if a file           return (string) $value->getPath() != '';// can't be null       }   //in the end, we will found only this value parameters has value whatever it is,just return true.       return true;   }//Validate a required attribute is exists   /**    * Validate the given attribute is filled if it is present.    *    * @param  string  $attribute    * @param  mixed   $value    * @return bool    */   protected function validateFilled($attribute, $value)   {       if (array_key_exists($attribute, $this->data) || array_key_exists($attribute, $this->files)) {           return $this->validateRequired($attribute, $value);// a filled just a required wrap       }// two type       return true;// normal it is true   }// present : now// means this attribute just has a value   /**    * Determine if any of the given attributes fail the required test.    *    * @param  array  $attributes    * @return bool    */   protected function anyFailingRequired(array $attributes)   {       foreach ($attributes as $key) {           if (! $this->validateRequired($key, $this->getValue($key))) {               return true;           }       }// same to ditto    // ues a loop about this attribute       return false;   }//Determine if any of the given attributes fail the required test.   /**    * Determine if all of the given attributes fail the required test.    *    * @param  array  $attributes    * @return bool    */   protected function allFailingRequired(array $attributes)   {       foreach ($attributes as $key) {           if ($this->validateRequired($key, $this->getValue($key))) {               return false;           }       }       return true;   }// all Fail just any ,the same , fool or stupid ?