email = strtolower($email); $validator = Validator::make(['email' => $this->email], [ 'email' => ['required', 'email:rfc', 'max:254'], ]); if ($this->firstName !== null && strlen($this->firstName) > 100) { throw new InvariantException('First name cannot be longer than 100 characters', ['first_name']); } if ($this->lastName !== null && strlen($this->lastName) > 100) { throw new InvariantException('Last name cannot be longer than 100 characters', ['last_name']); } if ($validator->fails()) { throw new InvariantException($validator->errors()->first('email'), ['email']); } } }