src/Form.php
public function expect( $name, $filter, $options = null ) {
		$options = ( is_array( $options ) ) ? $options : [];
		$flags = null;
		$required = false;
		$validate = null;

		if ( isset( $options['flags'] ) ) {
			$flags = $options['flags'];
			unset( $options['flags'] );
		}

		if ( isset( $options['required'] ) ) {
			$required = $options['required'];
			unset( $options['required'] );
		}

		if ( isset( $options['validate'] ) ) {
			$validate = $options['validate'];
			unset( $options['validate'] );
		}

		if ( $filter === \FILTER_CALLBACK ) {
			if ( !isset( $options['callback'] ) ||
				!is_callable( $options['callback'] )
			) {
				throw new \InvalidArgumentException(
					'FILTER_CALLBACK requires a valid callback.'
				);
			}
			$options = $options['callback'];
		}

		$this->params[$name] = [
			'filter'   => $filter,
			'flags'    => $flags,
			'options'  => $options,
			'required' => $required,
			'validate' => $validate,
		];

		return $this;
	}
public function expect( $name, $filter, $options = null ) {
		$options = ( is_array( $options ) ) ? $options : [];
		$flags = null;
		$required = false;
		$validate = null;

		if ( isset( $options['flags'] ) ) {
			$flags = $options['flags'];
			unset( $options['flags'] );
		}

		if ( isset( $options['required'] ) ) {
			$required = $options['required'];
			unset( $options['required'] );
		}

		if ( isset( $options['validate'] ) ) {
			$validate = $options['validate'];
			unset( $options['validate'] );
		}

		if ( $filter === \FILTER_CALLBACK ) {
			if ( !isset( $options['callback'] ) ||
				!is_callable( $options['callback'] )
			) {
				throw new \InvalidArgumentException(
					'FILTER_CALLBACK requires a valid callback.'
				);
			}
			$options = $options['callback'];
		}

		$this->params[$name] = [
			'filter'   => $filter,
			'flags'    => $flags,
			'options'  => $options,
			'required' => $required,
			'validate' => $validate,
		];

		return $this;
	}
public function expect ( $ name , $ filter , $ options = null ) { $ options = ( is_array ( $ options ) ) ? $ options : [ ] ; $ flags = null ; $ required = false ; $ validate = null ; if ( isset ( $ options [ 'flags' ] ) ) { $ flags = $ options [ 'flags' ] ; unset ( $ options [ 'flags' ] ) ; } if ( isset ( $ options [ 'required' ] ) ) { $ required = $ options [ 'required' ] ; unset ( $ options [ 'required' ] ) ; } if ( isset ( $ options [ 'validate' ] ) ) { $ validate = $ options [ 'validate' ] ; unset ( $ options [ 'validate' ] ) ; } if ( $ filter === \ FILTER_CALLBACK ) { if ( ! isset ( $ options [ 'callback' ] ) || ! is_callable ( $ options [ 'callback' ] ) ) { throw new \ InvalidArgumentException ( 'FILTER_CALLBACK requires a valid callback.' ) ; } $ options = $ options [ 'callback' ] ; } $ this -> params [ $ name ] = [ 'filter' => $ filter , 'flags' => $ flags , 'options' => $ options , 'required' => $ required , 'validate' => $ validate , ] ; return $ this ; }
Add an input expectation.

Allowed options:
- default: Default value for missing input
- flags: Flags to pass to filter_var_array
- required: Is this input required?
- validate: Callable to perform additional validation
- callback: Callable for \FILTER_CALLBACK validation

@param string $name Parameter to expect
@param int $filter Validation filter(s) to apply
@param array $options Validation options
@return Form Self, for message chaining
Add an input expectation .