Skip to content

Conversation

@aydinfatih
Copy link
Contributor

@aydinfatih aydinfatih commented May 5, 2024

We cannot use integer, string, boolean, date etc methods via $request->safe().

When we want to use these methods via $request, it does not guarantee that the data is validated. With this PR, the following methods will be available based on validated data.

Also this PR will not cause a major change.

Example:

$request->safe()->filled('test');
$request->safe()->boolean('test');

Added

  • exists: Determine if the validated inputs contains a given input item key.
  • hasAny: Determine if the validated inputs contains any of the given inputs.
  • whenHas: Apply the callback if the validated inputs contains the given input item key.
  • filled: Determine if the validated inputs contains a non-empty value for an input item.
  • isNotFilled: Determine if the validated inputs contains an empty value for an input item.
  • anyFilled: Determine if the validated inputs contains a non-empty value for any of the given inputs.
  • whenFilled: Apply the callback if the validated inputs contains a non-empty value for the given input item key.
  • whenMissing: Apply the callback if the validated inputs is missing the given input item key.
  • keys: Get the keys for all of the validated input.
  • input: Retrieve an input item from the validated inputs.
  • str: Retrieve input from the validated inputs as a Stringable instance.
  • string: Retrieve input from the validated inputs as a Stringable instance.
  • boolean: Retrieve input as a boolean value.
  • integer: Retrieve input as an integer value.
  • float: Retrieve input as a float value.
  • date: Retrieve input from the validated inputs as a Carbon instance.
  • enum: Retrieve input from the validated inputs as an enum.
  • dd: Dump the validated inputs items and end the script.
  • dump: Dump the items.

Changed

  • Add $key prop to collect method in ValidatedInput

@aydinfatih aydinfatih changed the title [10.x] Added InteractsWithInput methods to ValidatedInput [10.x] Add InteractsWithInput methods to ValidatedInput May 5, 2024
@NickSdot NickSdot mentioned this pull request May 6, 2024
@taylorotwell
Copy link
Member

Please re-send this to 11.x branch.

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