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

Improve optional argument #692

Open
camlafit opened this issue Nov 30, 2023 · 0 comments
Open

Improve optional argument #692

camlafit opened this issue Nov 30, 2023 · 0 comments

Comments

@camlafit
Copy link
Contributor

camlafit commented Nov 30, 2023

Hi

Looks possible to improve optional argument and reduce case with error.
I've found an old issue at SO : https://stackoverflow.com/questions/21241675/service-with-many-optional-parameters-with-restler

In validator.ph at https://github.com/Luracast/Restler/blob/master/src/Data/Validator.php#L512

I propose to add this patch :

	    if (!$info->required && isset($info->default) && empty($input)) {
	    	$input = $info->default;
	    }

After default value is checked as any other input and must be compliant with other annotation/configuration set.

In this case annotation must be set with :

@param string $state {@required false} {@default defaultvalue}

If this idea is not too bad I can propose a related pull request

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

No branches or pull requests

1 participant