Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.7] Add starts with validation #26612

Merged
merged 1 commit into from
Nov 25, 2018
Merged

[5.7] Add starts with validation #26612

merged 1 commit into from
Nov 25, 2018

Conversation

timacdonald
Copy link
Member

@timacdonald timacdonald commented Nov 25, 2018

This PR introduces a "starts with" validation rule. The request input value must start with one of the given rule parameters.

Here is an example of how you could use with stripe credentials:

public function rules()
{
    return [
        'stripe_publishable_key' => [
            'starts_with:pk_test_,pk_live_',
        ],
        'stripe_secret_key' => [
            'starts_with:sk_live_,sk_test_',
        ],
    ];
}

Granted this can be done easily with Regex or a custom validation rule already. I'm also conscious that you probably don't want to introduce a bunch of validation rules that are already easily achieved, however I needed this on a couple of projects and thought it might be handy in core if others think it would be useful to them

@taylorotwell taylorotwell merged commit 5f6d9a4 into laravel:5.7 Nov 25, 2018
fkeloks added a commit to fkeloks/framework that referenced this pull request Nov 25, 2018
nadinengland pushed a commit to engageinteractive/laravel that referenced this pull request Jan 25, 2019
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.

None yet

2 participants