Active Storage doesn't have validations yet.
We can restrict the accepted file types in the form:
<div class="field">
<%= f.label :deliverable %>
<%= f.file_field :deliverable, direct_upload: true,
accept: 'application/pdf,
application/zip,application/vnd.openxmlformats-officedocument.wordprocessingml.document' %>
</div>
And add a custom validation in the model:
class Item
has_one_attached :document
validate :correct_document_mime_type
private
def correct_document_mime_type
if document.attached? && !document.content_type.in?(%w(application/msword application/pdf))
errors.add(:document, 'Must be a PDF or a DOC file')
end
end
end
Storing stuff is a job for your suitcase.
Checking that there isn't a bomb in there is a job for the xray, the mass spectrometer and security team at the airport.
They're just completely separate jobs.
Add to that the fact that you could be storing images, word documents, music files, videos, gifs, pdfs, .mmw files (a custom file format for one of my apps) or a gazillion other things. It would be ridiculous for rails to try to build secure validation for all those types into their 'suitcase' functionality.