<?php
namespace Moto\Application\Profile; use Moto\InputFilter\AbstractInputFilter; class ChangePasswordFilter extends AbstractInputFilter { protected $_name = 'profile.change:password'; public function init() { foreach (array('old', 'new', 'confirm') as $prefix) { $validators = array( array( 'name' => 'StringLength', 'options' => array( 'encoding' => 'UTF-8', 'min' => 6, 'max' => 100, ), ) ); if ($prefix == 'confirm') { $validators[] = array( 'name' => 'Identical', 'options' => array( 'token' => 'new_password' ) ); } $this->add(array( 'name' => $prefix . '_password', 'required' => true, 'filters' => array( array('name' => 'StripTags'), array('name' => 'StringTrim'), ), 'validators' => $validators )); } } } 