Class OptionalInputFilter

Summary

Fully Qualified Name: Laminas\InputFilter\OptionalInputFilter
Extends: InputFilter

Description

InputFilter which only checks the containing Inputs when non-empty data is set, else it reports valid

This is analog to {@see \Laminas\InputFilter\Input} with the option ->setRequired(false)

Methods

Name Description Defined By
add() Add an input to the input filter InputFilter
count() Countable: number of inputs in this input filter BaseInputFilter
get() Retrieve a named input BaseInputFilter
getFactory() Get factory to use when adding inputs and filters by spec InputFilter
getInputs() Get an array of all inputs BaseInputFilter
getInvalidInput() Return a list of inputs that were invalid. BaseInputFilter
getMessages() Return a list of validation failure messages BaseInputFilter
getRawValue() Retrieve a raw (unfiltered) value from a named input BaseInputFilter
getRawValues() Return a list of unfiltered values BaseInputFilter
getUnfilteredData() BaseInputFilter
getUnknown() Return the unknown input BaseInputFilter
getValidInput() Return a list of inputs that were valid. BaseInputFilter
getValue() Retrieve a value from a named input BaseInputFilter
getValues() Return a list of filtered values, or null if the data was missing entirely Null is returned instead of an empty array to prevent it being passed to a hydrator, which would likely cause failures later on in your program Fallbacks for the inputs are not respected by design OptionalInputFilter
has() Test if an input or input filter by the given name is attached BaseInputFilter
hasUnknown() Is the data set has unknown input ? BaseInputFilter
init() This function is automatically called when creating element with factory. It allows to perform various operations (add elements. BaseInputFilter
isValid() Run validation, or return true if the data was empty OptionalInputFilter
merge() Merges the inputs from an InputFilter into the current one BaseInputFilter
remove() Remove a named input BaseInputFilter
replace() Replace a named input BaseInputFilter
setData() Set data to use when validating and filtering OptionalInputFilter
setFactory() Set factory to use when adding inputs and filters by spec InputFilter
setUnfilteredData() BaseInputFilter
setValidationGroup() Provide a list of one or more elements indicating the complete set to validate BaseInputFilter

Method Details

add()

Add an input to the input filter

Parameter Name Type Description
$input array|\Traversable|\InputInterface|\InputFilterInterface
$name null|string

Returns: \InputFilter

count()

Countable: number of inputs in this input filter

Only details the number of direct children.

Returns: int

get()

Retrieve a named input

Parameter Name Type Description
$name string

Returns: \InputInterface|\InputFilterInterface

getFactory()

Get factory to use when adding inputs and filters by spec

Lazy-loads a Factory instance if none attached.

Returns: \Factory

getInputs()

Get an array of all inputs

Returns: \InputInterface[]|\InputFilterInterface[]

getInvalidInput()

Return a list of inputs that were invalid.

Implementations should return an associative array of name/input pairs that failed validation.

Returns: \InputInterface[]

getMessages()

Return a list of validation failure messages

Should return an associative array of named input/message list pairs. Pairs should only be returned for inputs that failed validation.

Returns: array

getRawValue()

Retrieve a raw (unfiltered) value from a named input

Parameter Name Type Description
$name string

Returns: mixed

getRawValues()

Return a list of unfiltered values

List should be an associative array of named input/value pairs, with the values unfiltered.

Returns: array

getUnfilteredData()

Returns: array|object

getUnknown()

Return the unknown input

Returns: array

getValidInput()

Return a list of inputs that were valid.

Implementations should return an associative array of name/input pairs that passed validation.

Returns: \InputInterface[]

getValue()

Retrieve a value from a named input

Parameter Name Type Description
$name string

Returns: mixed

getValues()

Return a list of filtered values, or null if the data was missing entirely Null is returned instead of an empty array to prevent it being passed to a hydrator, which would likely cause failures later on in your program Fallbacks for the inputs are not respected by design

Returns: array|null

has()

Test if an input or input filter by the given name is attached

Parameter Name Type Description
$name string

Returns: bool

hasUnknown()

Is the data set has unknown input ?

Returns: bool

init()

This function is automatically called when creating element with factory. It allows to perform various operations (add elements.

..)

Returns: void

isValid()

Run validation, or return true if the data was empty

{@inheritDoc}

Parameter Name Type Description
$context

Returns:

merge()

Merges the inputs from an InputFilter into the current one

Parameter Name Type Description
$inputFilter \BaseInputFilter

Returns: self

remove()

Remove a named input

Parameter Name Type Description
$name string

Returns: \InputFilterInterface

replace()

Replace a named input

Parameter Name Type Description
$input mixed Any
$name string Name

Returns: self

setData()

Set data to use when validating and filtering

Parameter Name Type Description
$data iterable|mixed must

Returns: \InputFilterInterface

setFactory()

Set factory to use when adding inputs and filters by spec

Parameter Name Type Description
$factory \Factory

Returns: \InputFilter

setUnfilteredData()

Parameter Name Type Description
$data array|object

Returns: $this

setValidationGroup()

Provide a list of one or more elements indicating the complete set to validate

When provided, calls to {@link isValid()} will only validate the provided set.

If the initial value is {@link VALIDATE_ALL}, the current validation group, if any, should be cleared.

Implementations should allow passing a single array value, or multiple arguments, each specifying a single input.

Parameter Name Type Description
$name mixed

Returns: \InputFilterInterface

Top