Policy vs FieldPolicy
I haven't used FieldPolicy before, but lets say I have a :role attribute that I want to control changes to. I.e: :god should be able to create users with all roles, :admin should only be able to create :admin and :user, and :user should not be able to create any roles - but still able to edit their own account i.e: change their email etc. Would a field policy be the place for that these days?
16 Replies
field policies are only for reading, not for modifying
So you'd use policies in your case
ššæ cheers š
We may extend field policies into writing as well, but it will require new kinds of checks and that kind of thing
so field policies are specifically for the field to be populated in the struct?
i.e: only supervisors can see a certain attribute
yep, exactly
when a field policy fails, its value is replaced with
%Ash.ForbiddenField{}
I'm going to get GPT to read the docs and add an ELI5 section at the top of each section š¤£
and hidden in APIs accordingly
lol, honestly not a bad idea dude
prompt: "Assume I'm an idiot"
š¤£
š GPT behind the scenes: "way ahead of you"
I really want to get back to do a documentation push, bt I need to finish the other features I'm working on first
Probably another month or two, but maybe more
not bad tbh
pretty much lol

its a bit terse, and I'd probably add the addendum about only being used for reads
but it is a good start
yup
I asked it to be terse haha
before asking it to be terse

We should make a bot that makes ELI5 PRs to repos š
maintainers would love us!