Skip to content

[12.x] InteractsWithData::boolean isn't parsing strings as booleans #59703

@dima2306

Description

@dima2306

Laravel Version

12.56.0

PHP Version

8.5.3

Database Driver & Version

mysql, 11.8.6-MariaDB-ubu2404-log

Description

Illuminate\Foundation\Http\FormRequest's boolean() method isn't parsing "true" correctly as from the method's description is clear:

Returns true when value is "1", "true", "on", and "yes". Otherwise, returns false.

On the validation step I get error: 422 field must be true or false

Steps To Reproduce

  1. Create any form request
  2. Add any rule to validate as boolean
  3. pass from the frontend added-rule=true
  4. validate in the controller with $request->boolean('added-rule')
  5. validation will fail

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions