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

Don’t cast as boolean, do validate as boolean for User validation #13546

Merged
merged 4 commits into from
Aug 31, 2023

Conversation

snipe
Copy link
Owner

@snipe snipe commented Aug 30, 2023

This should make the behavior of the API for boolean fields a little more consistent. What's goofy though is if you're using postman, this fails using true/false, but works with 1 or 0.

Screenshot 2023-08-30 at 4 42 42 PM Screenshot 2023-08-30 at 4 42 48 PM

I guess we just have to document that in the API docs. :-/

@snipe snipe changed the title Don’t cast as boolean, validate as boolean Don’t cast as boolean, do validate as boolean for User API Aug 30, 2023
@what-the-diff
Copy link

what-the-diff bot commented Aug 30, 2023

PR Summary

  • Modification in User Model Attributes
    The attributes activated and vip are no longer part of the $casts array in the User model. Instead, a new attribute called autoassign_licenses has been introduced.

  • Enhancement in Validation Rules
    The User model has been updated with new validation rules. These rules are specifically designed for the state, country, zip, vip, remote, and activated attributes to maintain data integrity and consistency.

@snipe snipe changed the title Don’t cast as boolean, do validate as boolean for User API Don’t cast as boolean, do validate as boolean for User validation Aug 30, 2023
@snipe snipe requested review from uberbrady and marcusmoore August 30, 2023 15:45
@snipe
Copy link
Owner Author

snipe commented Aug 30, 2023

Hm, looks like those tests are failing, but I'm not sure (yet) if that's because the tests need to be updated or whether this actually breaks stuff.

@marcusmoore
Copy link
Collaborator

👀 gonna check it out

@marcusmoore
Copy link
Collaborator

@snipe yeah for the tests we can change the assertions to

$this->assertEquals(1, $user->refresh()->activated);
$this->assertEquals(0, $user->refresh()->activated);
// and
$this->assertEquals(1, $admin->refresh()->activated);

Want me to push a commit to your branch?

@snipe
Copy link
Owner Author

snipe commented Aug 30, 2023

Thanks! I ran out for a snack but I’ll handle that when I get back to my desk.

@snipe
Copy link
Owner Author

snipe commented Aug 30, 2023

@marcusmoore

Want me to push a commit to your branch?

Totes up to you. We’re on our midday break (a little late tho) so we won’t be back until the standup

@marcusmoore
Copy link
Collaborator

Pushed 👍🏾

Copy link
Collaborator

@marcusmoore marcusmoore left a comment

Choose a reason for hiding this comment

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

This seems to make sense.

Should we check other models for the same issue? byod on Asset for example.

@snipe
Copy link
Owner Author

snipe commented Aug 30, 2023

Yeah, probably - it's the postman fuckery that made it misleading when I first wrote it. :(

@snipe snipe merged commit 9a0f691 into develop Aug 31, 2023
@snipe snipe deleted the fixes/make_boolean_user_fields_more_consistant branch August 31, 2023 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants