hyku
hyku copied to clipboard
I102 valkyrie validations
Create change set for model resources and a TitleValidator.
Enforce the validator with generic_work_resource_cs = GenericWorkChangeSet.new(GenericWorkResource.new).
generic_work_resource_cs.valid? => false
generic_work_resource_cs.errors.messages => => {:title=>["can't be blank", "Your work must have a title."]}
Issue:
- https://github.com/scientist-softserv/hykuup_knapsack/issues/102
Docs:
- https://github.com/samvera/valkyrie/wiki/Persisting-changes-through-synchronization#successfully-change-and-save
TODO
- [x] Confirm via rails console
- [ ] Confirm via UI/manual work creation
consider making a default changeset
As discussed with LaRita, we're holding off on this merge. Is this the right way to do this? Can validations be enforced using the yaml?
When I made title not be a required field on the form, I can still successfully save a generic work resource from the ui, even with the validator. Perhaps it doesn't go through the changeset??
Update: it inherits from Hyrax::ChangeSet 🤔 which doesn't have a title validation. How do I make the resource forms use their respective changesets?