title: Lumen Custom Validation
body: <p>I am trying to implement a custom validation rule within lumen and I am following the docs for lumen 5.6. It says to refer to laravel validation to see how to use the validation. I am currently trying to make a validation to check if the value is a true null or not. So $x === "" would mean it fails Here is my rule located in App\Rules folder I created.</p>
  
  <pre><code>&lt;?php
  
  namespace App\Rules;
  
  use Illuminate\Contracts\Validation\Rule;
  
  class TrueNull implements Rule
  {
      /**
       * Determine if the validation rule passes.
       *
       * @param  string  $attribute
       * @param  mixed  $value
       * @return bool
       */
      public function passes($attribute, $value)
      {
          if($value === "") {
              return false;
          } else {
              return true;
          }
      }
  
      /**
       * Get the validation error message.
       *
       * @return string
       */
      public function message()
      {
          return 'The :attribute cannot be an empty string.';
      }
  }
  </code></pre>
  
  <p>I copied this straight from lumen docs and make my modification to the passes function. Within my modal have </p>
  
  <pre><code>use Illuminate\Auth\Authenticatable;
  use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
  use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
  use Illuminate\Database\Eloquent\Model;
  use Laravel\Lumen\Auth\Authorizable;
  use App\Rules\TrueNull;
  use Validator;
  </code></pre>
  
  <p>Then </p>
  
  <pre><code>public function validate($data)
  {
      // make a new validator object
      $v = Validator::make($data, 
      [
          'x' =&gt; ['regex:/^(?=.+)(?:[1-9]\d*|0)?(?:\.\d+)?$/', new TrueNull]
      ]
  }
  </code></pre>
  
  <p>But the validation for TrueNull never happens am I missing a connection or something its really frustrating because the docs says this should work.
  Here is my controller calling the update I am validating.</p>
  
  <pre><code>public function update(Request $request, $id)
      {
          /*
              In middleware need to add community id to request.
          */
          try {
              $site = Site::findOrFail($id);
  
              if ($site-&gt;validate($request-&gt;all())) {
                  $site-&gt;fill($request-&gt;all());
  
                  // save
                  $site-&gt;save();
              } else {
                  return response()-&gt;json($site-&gt;errors(), 422);
              }
          } catch (Exception $e) {
              return response()-&gt;json($e, 422);
          }
  
          return response()-&gt;json($site, 200);
      }
  </code></pre>