https://cerbos.dev logo
#help
Title
# help
m

Margarit Zisi

08/22/2023, 12:16 PM
hello guys, i'm creating a condition that checks if any of the objects inside entities contains a role called 'USER' but it always returns false even though i have an object with the role of 'USER'.Is it something wrong with my condition ? Example of entities => entities { <uuid>: { role: 'USER' }, <uuid>: { role: 'MANAGER' } }
a

Alex Olivier (Cerbos)

08/22/2023, 12:19 PM
Hey
Inside the map, you just need to do
.map(x, x.role === 'USER')
correction
.exists(x, x.role == 'USER')
exists checks for atleast one matching predicate, whilst map is for transforming the list
m

Margarit Zisi

08/22/2023, 12:24 PM
thanks Alex
a

Alex Olivier (Cerbos)

08/22/2023, 12:31 PM
Whats your use case for Cerbos?
m

Margarit Zisi

08/22/2023, 12:39 PM
In a few words one user can have different locations with different roles. And based on the roles i check the permission
a

Alex Olivier (Cerbos)

08/22/2023, 12:40 PM
Sounds a perfect use case for Cerbos 🙂 If you want we run free workshops to help you get started - you can book it here if you would like https://go.cerbos.io/workshop
m

Margarit Zisi

08/22/2023, 12:48 PM
will do when i'll need help. thanks a lot
2 Views