M
Manifest•2w ago
BennySama

API Policies - Custom Policy

It's less of a question, but more of a suggestion I would like to ask here, maybe there is also a solution for it already. If we will get a working "default" option like this example:
entities:
User:
authenticable: true
properties:
- name
- {name: role, type: choice, options: {values: ["admin", "mod", "user"], default: "user"}}
entities:
User:
authenticable: true
properties:
- name
- {name: role, type: choice, options: {values: ["admin", "mod", "user"], default: "user"}}
Wouldn't it be also great to make our own custom policy, where it doesn't necessarily has to depend on the 4 access types? I am going to take the Invoice example to show what I mean
entities:
Invoice 🧾:
properties:
- number
- { name: issueDate, type: date }
policies:
create:
- { access: custom, allow: UserRole ["admin", "mod"] }
update:
- access: admin
delete:
- access: forbidden


policies:
UserRole:
User:
- {property: role, policy: restricted}
entities:
Invoice 🧾:
properties:
- number
- { name: issueDate, type: date }
policies:
create:
- { access: custom, allow: UserRole ["admin", "mod"] }
update:
- access: admin
delete:
- access: forbidden


policies:
UserRole:
User:
- {property: role, policy: restricted}
I hope that's understandable enough, but if there are more ideas or question, I'll be happy to answer them
2 Replies
BennySama
BennySamaOP•2w ago
Maybe it's just my habit, but I wouldn't want to create 3 Entities, but keep one user-Entity, but with 3 different roles
brunobuddy
brunobuddy•2w ago
@BennySama yes for both ! - Default values are on the pipe https://github.com/mnfst/manifest/issues/263 - Policies were just a first phase were you can select the policy you want from a list. The following will be to be able to add your own, pretty much like you said. Thank you for those suggestions, I think that you understood perfectly where Manifest is aiming
GitHub
Allow default values for record creation · Issue #263 · mnfst/manif...
We should be able to set the default value for properties when nothing is passed.

Did you find this page helpful?