magento / magento/community-features

Add the possibility to append additional validation callbacks in Magento\Config\Model\Config\Backend\File

Open
#336 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
46
Forks
14
PR merge metrics
No merged PRs in 30d

Description

### Description (*)

Consider the case of a custom file upload.
We can extend the File class and add, let's say, a specific file extension via _getAllowedExtensions
Why we shouldn't be able to add one or more callbacks for validations too ?
At the moment the only way to do it, it's to completely override the beforeSave() function as we have no method (or property) we can use to set an array of additional callbacks.
The method addValidateCallback is called to add only "file size validation"

### Expected behavior (*)

A way to specify additional validation callbacks

### Benefits

Cleaner code
Less overridden magento code

### Additional information

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting Magento\Config\Model\Config\Backend\File, especially beforeSave() and addValidateCallback(). Determine how validation callbacks are currently stored and invoked, then define the registration behavior needed for additional callbacks. Done means custom file-upload validation can be added without completely overriding beforeSave().

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.