Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

LaraBug/larabug-app

218 stars
2 code files
View LaraBug/larabug-app on GitHub

app/Rules/StartsWith.php

Open in GitHub
use Illuminate\Contracts\Validation\Rule;
 
class StartsWith implements Rule
{
public function passes($attribute, $value)
{
return starts_with($value, $this->starts);
}
 
public function message()
{
$str = '';
if (is_array($this->starts)) {
$i = 0;
foreach ($this->starts as $start) {
$str .= ($i !== 0 ? 'or' : null) . ' ' . $start;
$i++;
}
} else {
$str = $this->starts;
}
 
return 'The :attribute must start with ' . $str;
}
}

app/Http/Requests/ProjectRequest.php

Open in GitHub
use App\Rules\StartsWith;
use Illuminate\Foundation\Http\FormRequest;
 
class ProjectRequest extends FormRequest
{
public function rules()
{
return [
'slack_webhook' => [
'url',
'nullable',
new StartsWith('https://hooks.slack.com/services/')
],
'discord_webhook' => [
'url',
'nullable',
new StartsWith(['https://discordapp.com/api/webhooks/', 'https://discord.com/api/webhooks/'])
],
];
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.