allow_null) { $this->error = 'presence_of'; } return is_null($this->error); } // ------------------------------------------------------------- // Make sure the attribute is not an empty string. An error // will be raised if the attribute is empty and empty strings // are not allowed, halting the child's validation. // ------------------------------------------------------------- elseif (Str::length((string) $attributes[$attribute]) == 0 and ! $this->allow_empty) { $this->error = 'presence_of'; return false; } } /** * Allow a empty and null to be considered valid. * * @return Nullable_Rule */ public function not_required() { return $this->allow_empty()->allow_null(); } /** * Allow empty to be considered valid. * * @return Nullable_Rule */ public function allow_empty() { $this->allow_empty = true; return $this; } /** * Allow null to be considered valid. * * @return Nullable_Rule */ public function allow_null() { $this->allow_null = true; return $this; } }