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

Boolean with "true" and "false" doesnt work #2857

Closed
OxygenLack opened this issue Dec 11, 2020 · 5 comments
Closed

Boolean with "true" and "false" doesnt work #2857

OxygenLack opened this issue Dec 11, 2020 · 5 comments

Comments

@OxygenLack
Copy link

  • Panel
  • Version of Panel/Daemon: 1.1.3
  • Server's OS: Linux v2202010131063129336 4.19.0-13-amd64 Migrate ability to reset passwords #1 SMP Debian 4.19.160-2 (2020-11-28) x86_64 GNU/Linux
  • Your Computer's OS & Browser: Windows 10 v2004 (build 19041.630) Chrome (87.0.4280.88)

Please provide additional information too, depending on what you have issues with:
I tried to add a variable as an boolean for Nest configurations which should require "true & false".
When I tried to set a server up it said that I the variable should be "true" or "false". But it clearly is true. 0 and 1 work normally...

PHP-Version: PHP 7.3.19-1~deb10u1
Docker Version: Docker Inc., v0.9.1-beta3

Steps to reproduce the behavior:

  1. Go to Nest Eggs
  2. Create a variable with a required boolean and save
  3. Go to Servers
  4. Create a Server with the created Nest Egg and enter the required boolean as true/false

Expected behavior:
Accepting true or false as valid boolean. (It accepts 0 and 1)
boolean
booleanerror

@schrej schrej added the bug Something that's not working as it's intended to be. label Dec 11, 2020
@DaneEveritt
Copy link
Member

This is working as intended: https://laravel.com/docs/7.x/validation#rule-boolean

String "true"/"false" are not accepted under the boolean rule in Laravel.

@DaneEveritt DaneEveritt removed the bug Something that's not working as it's intended to be. label Dec 11, 2020
@Software-Noob
Copy link
Member

This is working as intended: https://laravel.com/docs/7.x/validation#rule-boolean

String "true"/"false" are not accepted under the boolean rule in Laravel.

Unless I'm blind it states that it indeed accepts them.

The field under validation must be able to be cast as a boolean. Accepted input are true, false, 1, 0, "1", and "0".

@sergejostir
Copy link
Contributor

Your input is a string, so "true" or "false" and these are not accepted.

@schrej
Copy link
Member

schrej commented Dec 11, 2020

Shouldn't this then just be a Checkbox or Dropdown instead of a textbox?

@DaneEveritt
Copy link
Member

Probably, yes, but that is unrelated to this issue specifically (and there is an open issue somewhere about adding those types of fields).

@Software-Noob the true and false in the docs refer to boolean, not string literals. (bool)"true" and (bool)"false" in PHP will always give you true.

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

5 participants