Skip to content

Conversation

@KIKOmanasijev
Copy link
Contributor

This PR adds a new isEmail() method to the Stringable class for quick email format validation. The method provides a convenient way to check if a string is a valid email address.

Example

Current approach requires breaking the fluent chain:

class UpdateBackupEmailAction
{
   public function execute(User $user, array $data): bool
   {
       if (isset($data['backup_email']) && !Str::isEmail($data['backup_email'])) {
           throw new InvalidArgumentException('Invalid backup email format');
       }
       
       return $user->update(['backup_email' => $data['backup_email']]);
   }
}

@shaedrich
Copy link
Contributor

Is there a reason why you don't want to offer the rich validation options the email Validator rule offers?

@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If applicable, please consider releasing your code as a package so that the community can still take advantage of your contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants