# \#laminas-inputfilter

**URL:** https://discourse.laminas.dev/tag/laminas-inputfilter/76.md

[Latest](https://discourse.laminas.dev/latest.md) · [Categories](https://discourse.laminas.dev/categories.md) · [Tags](https://discourse.laminas.dev/tags.md)

---

## [Best way to use Composition instead of Inheritance for Laminas Form Elements](https://discourse.laminas.dev/t/best-way-to-use-composition-instead-of-inheritance-for-laminas-form-elements/3978)

<div class="topic-metadata">

**Author:** [@earthiverse](https://discourse.laminas.dev/u/earthiverse)\
**Replies:** 6\
**Last updated:** [January 27, 2026, 11:43am UTC](https://discourse.laminas.dev/t/best-way-to-use-composition-instead-of-inheritance-for-laminas-form-elements/3978 "2026-01-27T11:43:34Z")

</div>

Right now we have inputs like this, which extend Select namespace Admin\\Form\\Input; use Admin\\Enum\\PeriodRange as PeriodRangeEnum; use Laminas\\Filter\\ToString; use Laminas\\Form\\Element\\Select; use Laminas\\Validator\\InA…

---

## [Why does InputFilter allow\_empty + required with ArrayInput differ to regular Inputs?](https://discourse.laminas.dev/t/why-does-inputfilter-allow-empty-required-with-arrayinput-differ-to-regular-inputs/3809)

<div class="topic-metadata">

**Author:** [@GLuskin](https://discourse.laminas.dev/u/GLuskin)\
**Replies:** 3\
**Last updated:** [December 10, 2024, 8:43am UTC](https://discourse.laminas.dev/t/why-does-inputfilter-allow-empty-required-with-arrayinput-differ-to-regular-inputs/3809 "2024-12-10T08:43:20Z")

</div>

Hi All I have been having issues dealing with arrays and the InputFilter’s “required” and “allow\_empty” options. It is my understanding that: required = The input array must contain the field name as a key allow\_empt…

---

## [Fieldset Validation Not Being Applied](https://discourse.laminas.dev/t/fieldset-validation-not-being-applied/3446)

<div class="topic-metadata">

**Author:** [@Saeven](https://discourse.laminas.dev/u/Saeven)\
**Replies:** 6\
**Last updated:** [August 22, 2023, 7:51pm UTC](https://discourse.laminas.dev/t/fieldset-validation-not-being-applied/3446 "2023-08-22T19:51:23Z")

</div>

Hello Laminas Community! I’ve got a simple fieldset that is successfully hydrating the expected entity, however, the validation in that fieldset’s getInputFilterSpecification is being ignored. The fieldset belongs to a…

---

## [Possible Bug validating non-text input](https://discourse.laminas.dev/t/possible-bug-validating-non-text-input/3418)

<div class="topic-metadata">

**Author:** [@juliangorge](https://discourse.laminas.dev/u/juliangorge)\
**Replies:** 14\
**Last updated:** [August 4, 2023, 10:37am UTC](https://discourse.laminas.dev/t/possible-bug-validating-non-text-input/3418 "2023-08-04T10:37:41Z")

</div>

Hey, Just a little bit of context: I’m using OptionalInputFilter into my forms because I have multiple inputs depending of others. For example: if you have to complete a payment form between Bank payment or Credit card…

---

## [How to validate form collections where context between collection elements also needs to be validated](https://discourse.laminas.dev/t/how-to-validate-form-collections-where-context-between-collection-elements-also-needs-to-be-validated/3393)

<div class="topic-metadata">

**Author:** [@oliver681](https://discourse.laminas.dev/u/oliver681)\
**Replies:** 0\
**Last updated:** [July 16, 2023, 3:45pm UTC](https://discourse.laminas.dev/t/how-to-validate-form-collections-where-context-between-collection-elements-also-needs-to-be-validated/3393 "2023-07-16T15:45:54Z")

</div>

I have a form containing a collection financingSources and the corresponding child fieldset FinancingSourceFieldset containing an input share. I want to validate both the respective fieldset’s inputs and the context of t…

---

## [Laminas Input Filter Issues](https://discourse.laminas.dev/t/laminas-input-filter-issues/3273)

<div class="topic-metadata">

**Author:** [@Super0Yt](https://discourse.laminas.dev/u/Super0Yt)\
**Replies:** 3\
**Last updated:** [April 4, 2023, 8:30pm UTC](https://discourse.laminas.dev/t/laminas-input-filter-issues/3273 "2023-04-04T20:30:37Z")

</div>

i am struggling to understand how i can use input filter but i can’t . firstly i use this video as resource to understand it : “PHP Laminas MVC Web Development - 04d Filtering and Validating Data - YouTube” i create a…

---

## [How to require a field only if some condition is true?](https://discourse.laminas.dev/t/how-to-require-a-field-only-if-some-condition-is-true/3197)

<div class="topic-metadata">

**Author:** [@valdinei](https://discourse.laminas.dev/u/valdinei)\
**Replies:** 11\
**Last updated:** [February 20, 2023, 7:57pm UTC](https://discourse.laminas.dev/t/how-to-require-a-field-only-if-some-condition-is-true/3197 "2023-02-20T19:57:43Z")

</div>

I have a field (let’s suppose it’s “prices”) that should only be required if other field (named “type”) is some value. I saw that if some Input it’s not required, the package ignore when value is not provided, so add a …

---

## [Limiting the uploded file size](https://discourse.laminas.dev/t/limiting-the-uploded-file-size/3089)

<div class="topic-metadata">

**Author:** [@sanjivsharmalv](https://discourse.laminas.dev/u/sanjivsharmalv)\
**Replies:** 4\
**Last updated:** [October 26, 2022, 7:08pm UTC](https://discourse.laminas.dev/t/limiting-the-uploded-file-size/3089 "2022-10-26T19:08:49Z")

</div>

How do I limit the uploaded file size. I have tried the following validator but it has not helped. It uploads files of all sizes: ... //Validator $inputFilter-\>add(\[ 'name' =\> 'my-file', …

---

## [VS Code doesn't recognize @psalm-import-type InputSpecification](https://discourse.laminas.dev/t/vs-code-doesnt-recognize-psalm-import-type-inputspecification/3090)

<div class="topic-metadata">

**Author:** [@ivel](https://discourse.laminas.dev/u/ivel)\
**Replies:** 6\
**Last updated:** [October 26, 2022, 6:51pm UTC](https://discourse.laminas.dev/t/vs-code-doesnt-recognize-psalm-import-type-inputspecification/3090 "2022-10-26T18:51:51Z")

</div>

Hello, It seems that VS Code with PHP tools does not detect the @psalm-import-type InputSpecification from InputFilterInterface in the Laminas\\InputFilter\\InputFilter (ver. 2.21.0), and throws a warning for “Unknown cla…

---

## [Filter that allows only files of special types(pdf, doc etc)](https://discourse.laminas.dev/t/filter-that-allows-only-files-of-special-types-pdf-doc-etc/3088)

<div class="topic-metadata">

**Author:** [@sanjivsharmalv](https://discourse.laminas.dev/u/sanjivsharmalv)\
**Replies:** 3\
**Last updated:** [October 25, 2022, 6:52pm UTC](https://discourse.laminas.dev/t/filter-that-allows-only-files-of-special-types-pdf-doc-etc/3088 "2022-10-25T18:52:39Z")

</div>

Do we have input filters that allows the user to upload file of specific types (pdf, doc, ,.odt etc) and do not permit to upload files of type - .png, jpg etc.

---

## [Input filter and boolean value](https://discourse.laminas.dev/t/input-filter-and-boolean-value/3069)

<div class="topic-metadata">

**Author:** [@MANDLA\_PILOT\_NKUNA](https://discourse.laminas.dev/u/MANDLA_PILOT_NKUNA)\
**Replies:** 0\
**Last updated:** [October 6, 2022, 5:02am UTC](https://discourse.laminas.dev/t/input-filter-and-boolean-value/3069 "2022-10-06T05:02:26Z")

</div>

I have this two fields one is Normal String the other One is Boolean, I am failing to get the boolean value from API but the string and integer I can get. public function \_\_construct($options = null) { parent::\_\_constr…

---

## [How do I validate boolean?](https://discourse.laminas.dev/t/how-do-i-validate-boolean/3052)

<div class="topic-metadata">

**Author:** [@sanjivsharmalv](https://discourse.laminas.dev/u/sanjivsharmalv)\
**Replies:** 7\
**Last updated:** [September 23, 2022, 10:19am UTC](https://discourse.laminas.dev/t/how-do-i-validate-boolean/3052 "2022-09-23T10:19:52Z")

</div>

In a form there are boolean fields my question is how do we validate boolean values or we can safely ignore validation for boolean. The same question arises for form elements - Select, Multi Select fields.

---

## [Right way of using AllowList filter](https://discourse.laminas.dev/t/right-way-of-using-allowlist-filter/3057)

<div class="topic-metadata">

**Author:** [@sanjivsharmalv](https://discourse.laminas.dev/u/sanjivsharmalv)\
**Replies:** 2\
**Last updated:** [September 23, 2022, 6:30am UTC](https://discourse.laminas.dev/t/right-way-of-using-allowlist-filter/3057 "2022-09-23T06:30:12Z")

</div>

What is the right way of using AllowList. I am trying to use it as follows. My question is how do I pass the list of values. $inputFilter-\>add(\[ 'name' =\> 'my-dsc-type', 'required' =\> tr…

---

## [Why allow\_empty is ineffective?](https://discourse.laminas.dev/t/why-allow-empty-is-ineffective/3032)

<div class="topic-metadata">

**Author:** [@sanjivsharmalv](https://discourse.laminas.dev/u/sanjivsharmalv)\
**Replies:** 1\
**Last updated:** [September 1, 2022, 9:18pm UTC](https://discourse.laminas.dev/t/why-allow-empty-is-ineffective/3032 "2022-09-01T21:18:34Z")

</div>

I have various form fields. Some of those form fields can have values while others may not have. So I have made those as required ‘false’ and also made them as allow\_empty true. Come what may I am still getting isEmpty w…

---

## [Collection Element Validation](https://discourse.laminas.dev/t/collection-element-validation/2635)

<div class="topic-metadata">

**Author:** [@mattG10](https://discourse.laminas.dev/u/mattG10)\
**Replies:** 22\
**Last updated:** [January 21, 2022, 9:06am UTC](https://discourse.laminas.dev/t/collection-element-validation/2635 "2022-01-21T09:06:31Z")

</div>

I have an application which has a base fieldset (Task) and collections (Roles) within that fieldset. I’ve setup validation to check the role collections are not empty but am struggling to get the system to validate the r…

---

## [Required Annotation in Laminas Form](https://discourse.laminas.dev/t/required-annotation-in-laminas-form/2818)

<div class="topic-metadata">

**Author:** [@makxk](https://discourse.laminas.dev/u/makxk)\
**Replies:** 10\
**Last updated:** [March 17, 2022, 7:35pm UTC](https://discourse.laminas.dev/t/required-annotation-in-laminas-form/2818 "2022-03-17T19:35:12Z")

</div>

Hi Folks! I have been trying to get rid of my form classes and use form annotations to create them; however, I stumbled upon a little something…: Given the following element: //use statement for completions sake use L…

---

## [Conditional Validation in a Fieldset](https://discourse.laminas.dev/t/conditional-validation-in-a-fieldset/2769)

<div class="topic-metadata">

**Author:** [@mattG10](https://discourse.laminas.dev/u/mattG10)\
**Replies:** 1\
**Last updated:** [February 17, 2022, 12:55pm UTC](https://discourse.laminas.dev/t/conditional-validation-in-a-fieldset/2769 "2022-02-17T12:55:42Z")

</div>

I’m trying to figure out the best way to validate the input on a fieldset. The validation rules should work so if AcceptDeclineAssignment is set to Accept then person, CompanyName, ContactName, ContactEmail, ContactPhone…

---

## [How to use RecordExists validator in Callback validator?](https://discourse.laminas.dev/t/how-to-use-recordexists-validator-in-callback-validator/2576)

<div class="topic-metadata">

**Author:** [@jobsfan](https://discourse.laminas.dev/u/jobsfan)\
**Replies:** 12\
**Last updated:** [November 5, 2021, 7:03am UTC](https://discourse.laminas.dev/t/how-to-use-recordexists-validator-in-callback-validator/2576 "2021-11-05T07:03:41Z")

</div>

in getInputFilterSpecification to some form element \[ 'name' =\> 'targetid', //目标的id，例如帖子的id 'required' =\> true, 'filters' =\> \[ \['name' =\> ToInt::class…

---

## [ArrayAccess arg type in BaseInputFilter::validateInputs()](https://discourse.laminas.dev/t/arrayaccess-arg-type-in-baseinputfilter-validateinputs/2567)

<div class="topic-metadata">

**Author:** [@Illia\_Hapak](https://discourse.laminas.dev/u/Illia_Hapak)\
**Replies:** 2\
**Last updated:** [October 29, 2021, 3:19pm UTC](https://discourse.laminas.dev/t/arrayaccess-arg-type-in-baseinputfilter-validateinputs/2567 "2021-10-29T15:19:23Z")

</div>

BaseInputFilter::$data property has null|array in DocBlock. Also in BaseInputFilter::setData() it makes sure that we initialize property with an array. But for some reason BaseInputFilter::validateInputs() in DocBlock we…

---

## [CollectionInputFilter - apply Validator/IsCountable](https://discourse.laminas.dev/t/collectioninputfilter-apply-validator-iscountable/2391)

<div class="topic-metadata">

**Author:** [@Vaclav\_Vanik](https://discourse.laminas.dev/u/Vaclav_Vanik)\
**Replies:** 3\
**Last updated:** [July 20, 2021, 8:25am UTC](https://discourse.laminas.dev/t/collectioninputfilter-apply-validator-iscountable/2391 "2021-07-20T08:25:01Z")

</div>

Hi, I want to validate min/max count of items in CollectionInputFilter. My config is: \<?php declare(strict\_types=1); use Laminas\\InputFilter; use Laminas\\Validator; include\_once \_\_DIR\_\_ . '/vendor/autoload.php'; $c…

---

## [Laminas DI and InputFilterPluginManager](https://discourse.laminas.dev/t/laminas-di-and-inputfilterpluginmanager/2309)

<div class="topic-metadata">

**Author:** [@disasterdrop](https://discourse.laminas.dev/u/disasterdrop)\
**Replies:** 0\
**Last updated:** [May 19, 2021, 11:44am UTC](https://discourse.laminas.dev/t/laminas-di-and-inputfilterpluginmanager/2309 "2021-05-19T11:44:24Z")

</div>

Hi, i’m wondering how the laminas/di AOT Factories could be working with the InputFilterPluginManager. I’m having troubles to get it running in my mezzio application, because the init() method will not be called when t…

---

## [Question about filtered value by Laminas\\Filter\\Boolean](https://discourse.laminas.dev/t/question-about-filtered-value-by-laminas-filter-boolean/2217)

<div class="topic-metadata">

**Author:** [@shishi666](https://discourse.laminas.dev/u/shishi666)\
**Replies:** 3\
**Last updated:** [April 6, 2021, 6:59am UTC](https://discourse.laminas.dev/t/question-about-filtered-value-by-laminas-filter-boolean/2217 "2021-04-06T06:59:29Z")

</div>

Hy, I am confused with the following code and i would like to know what i am doing wrong. I use this code in Mezzio application $inputFilter = new \\Laminas\\InputFilter\\InputFilter(); $inputFilter-\>add(\[ 'name' =\> …

---

## [What does Laminas\\InputFilter\\FileInput do exactly?](https://discourse.laminas.dev/t/what-does-laminas-inputfilter-fileinput-do-exactly/2069)

<div class="topic-metadata">

**Author:** [@Fadi\_Obaji](https://discourse.laminas.dev/u/Fadi_Obaji)\
**Replies:** 3\
**Last updated:** [January 28, 2021, 10:36pm UTC](https://discourse.laminas.dev/t/what-does-laminas-inputfilter-fileinput-do-exactly/2069 "2021-01-28T22:36:44Z")

</div>

I’ve been researching Laminas documentation for their FIleInput class and i haven’t found a decent explanation of what those filters and validators actually do. I’m building a community website and planning to let users…

---

## [OptionalInputFilter does not contains set required method](https://discourse.laminas.dev/t/optionalinputfilter-does-not-contains-set-required-method/1982)

<div class="topic-metadata">

**Author:** [@eguvenc](https://discourse.laminas.dev/u/eguvenc)\
**Replies:** 1\
**Last updated:** [December 3, 2020, 10:52am UTC](https://discourse.laminas.dev/t/optionalinputfilter-does-not-contains-set-required-method/1982 "2020-12-03T10:52:14Z")

</div>

I could not see any setIsRequired() method in the OptionalInputFilter object how can i set it as required ?

---

## [How to validate object input?](https://discourse.laminas.dev/t/how-to-validate-object-input/1975)

<div class="topic-metadata">

**Author:** [@eguvenc](https://discourse.laminas.dev/u/eguvenc)\
**Replies:** 4\
**Last updated:** [December 3, 2020, 7:16am UTC](https://discourse.laminas.dev/t/how-to-validate-object-input/1975 "2020-12-03T07:16:25Z")

</div>

Hi,I found a solution for my previous question How to validate array inputs? - Questions / Components - Laminas Project Community Thanks. Now i am looking solution for associative way ? Is there any example validating…

---

## [No file was uploaded error Zend framework 3 validation](https://discourse.laminas.dev/t/no-file-was-uploaded-error-zend-framework-3-validation/1777)

<div class="topic-metadata">

**Author:** [@karen\_shahmuradyan](https://discourse.laminas.dev/u/karen_shahmuradyan)\
**Replies:** 1\
**Last updated:** [August 17, 2020, 4:15pm UTC](https://discourse.laminas.dev/t/no-file-was-uploaded-error-zend-framework-3-validation/1777 "2020-08-17T16:15:31Z")

</div>

I want use Callback validation but continue\_if\_empty not working for File it’s returning No file was uploaded error. But everything working for Input and Select . I need help with this. $this-\>add(\[ 'name' …

---

## [Inputfilter Authentication validator is fired even with a break\_on\_failure on previous inputfilter](https://discourse.laminas.dev/t/inputfilter-authentication-validator-is-fired-even-with-a-break-on-failure-on-previous-inputfilter/1720)

<div class="topic-metadata">

**Author:** [@Denis.S](https://discourse.laminas.dev/u/Denis.S)\
**Replies:** 6\
**Last updated:** [July 16, 2020, 10:44am UTC](https://discourse.laminas.dev/t/inputfilter-authentication-validator-is-fired-even-with-a-break-on-failure-on-previous-inputfilter/1720 "2020-07-16T10:44:02Z")

</div>

Hello, in a login form I have an email (required) and a password. I have 2 inputfilters, one for the email, the other for the password. The password Inputfilter has an Authentication Validator. This is an example I mad…
