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

✨ Introduce extensible settings rules for SetupRequest #4

Closed
wants to merge 1 commit into from

Conversation

yoerriwalstra
Copy link

No description provided.

Comment on lines +35 to +38
protected function settingsRules(): string|array
{
return 'array';
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know I suggested exactly this code but I'm wondering, isn't the following the same?

Suggested change
protected function settingsRules(): string|array
{
return 'array';
}
protected function settingsRules(): array
{
return ['array'];
}

Just so we avoid having to return string as well. Not sure if it will work!

Copy link
Author

@yoerriwalstra yoerriwalstra Jan 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will work, but we lose the flexibility to return, for example

'array|size:3'

Now that I'm thinking about it longer, I don't see how this helps us validate individual settings. In case of pay.nl, we want to be able to validate not just data.settings, but specifically data.settings.api_code, data.settings.api_token and data.settings.service_id. All those keys have to go directly into the array that is returned by rules(), it won't work with:

protected function settingsRules(): array
{
    return [
        'api_code' => 'required|string',
        ...
    ];
}

so, perhaps we should keep this SetupRequest as is, extend it in integrations that require additional validation and override the rules method there, like you suggested earlier:

public function rules(): array
{
    $rules = parent::rules();

    $rules['data.settings.api_code'] = ...;
 
   return $rules;
}

@yoan-myparcel
Copy link
Member

Closed because of @yoerriwalstra last comment - it is the case and we do not need this change in skeleton.

@yoan-myparcel yoan-myparcel deleted the extensible-setup-request branch January 16, 2024 14:41
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.

2 participants