1<?php
2/**
3 * Zend Framework (http://framework.zend.com/)
4 *
5 * @link      http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license   http://framework.zend.com/license/new-bsd New BSD License
8 */
9
10namespace Zend\InputFilter;
11
12use Countable;
13use Traversable;
14
15interface InputFilterInterface extends Countable
16{
17    const VALIDATE_ALL = 'INPUT_FILTER_ALL';
18
19    /**
20     * Add an input to the input filter
21     *
22     * @param  InputInterface|InputFilterInterface|array|Traversable $input
23     *     Implementations MUST handle at least one of the specified types, and
24     *     raise an exception for any they cannot process.
25     * @param  null|string $name Name used to retrieve this input
26     * @return InputFilterInterface
27     * @throws Exception\InvalidArgumentException if unable to handle the input type.
28     */
29    public function add($input, $name = null);
30
31    /**
32     * Retrieve a named input
33     *
34     * @param  string $name
35     * @return InputInterface|InputFilterInterface
36     */
37    public function get($name);
38
39    /**
40     * Test if an input or input filter by the given name is attached
41     *
42     * @param  string $name
43     * @return bool
44     */
45    public function has($name);
46
47    /**
48     * Remove a named input
49     *
50     * @param  string $name
51     * @return InputFilterInterface
52     */
53    public function remove($name);
54
55    /**
56     * Set data to use when validating and filtering
57     *
58     * @param  array|Traversable $data
59     * @return InputFilterInterface
60     */
61    public function setData($data);
62
63    /**
64     * Is the data set valid?
65     *
66     * @return bool
67     */
68    public function isValid();
69
70    /**
71     * Provide a list of one or more elements indicating the complete set to validate
72     *
73     * When provided, calls to {@link isValid()} will only validate the provided set.
74     *
75     * If the initial value is {@link VALIDATE_ALL}, the current validation group, if
76     * any, should be cleared.
77     *
78     * Implementations should allow passing a single array value, or multiple arguments,
79     * each specifying a single input.
80     *
81     * @param  mixed $name
82     * @return InputFilterInterface
83     */
84    public function setValidationGroup($name);
85
86    /**
87     * Return a list of inputs that were invalid.
88     *
89     * Implementations should return an associative array of name/input pairs
90     * that failed validation.
91     *
92     * @return InputInterface[]
93     */
94    public function getInvalidInput();
95
96    /**
97     * Return a list of inputs that were valid.
98     *
99     * Implementations should return an associative array of name/input pairs
100     * that passed validation.
101     *
102     * @return InputInterface[]
103     */
104    public function getValidInput();
105
106    /**
107     * Retrieve a value from a named input
108     *
109     * @param  string $name
110     * @return mixed
111     */
112    public function getValue($name);
113
114    /**
115     * Return a list of filtered values
116     *
117     * List should be an associative array, with the values filtered. If
118     * validation failed, this should raise an exception.
119     *
120     * @return array
121     */
122    public function getValues();
123
124    /**
125     * Retrieve a raw (unfiltered) value from a named input
126     *
127     * @param  string $name
128     * @return mixed
129     */
130    public function getRawValue($name);
131
132    /**
133     * Return a list of unfiltered values
134     *
135     * List should be an associative array of named input/value pairs,
136     * with the values unfiltered.
137     *
138     * @return array
139     */
140    public function getRawValues();
141
142    /**
143     * Return a list of validation failure messages
144     *
145     * Should return an associative array of named input/message list pairs.
146     * Pairs should only be returned for inputs that failed validation.
147     *
148     * @return string[]
149     */
150    public function getMessages();
151}
152