[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Installation 5 * 6 * @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org> 7 * @license GNU General Public License version 2 or later; see LICENSE.txt 8 */ 9 10 namespace Joomla\CMS\Installation\Form\Rule; 11 12 use Joomla\CMS\Filter\InputFilter; 13 use Joomla\CMS\Form\Form; 14 use Joomla\CMS\Form\FormRule; 15 use Joomla\Registry\Registry; 16 17 // phpcs:disable PSR1.Files.SideEffects 18 \defined('JPATH_BASE') or die; 19 // phpcs:enable PSR1.Files.SideEffects 20 21 /** 22 * Form Rule class for the username. 23 * 24 * @since 3.9.4 25 */ 26 class UsernameRule extends FormRule 27 { 28 /** 29 * Method to test a username 30 * 31 * @param \SimpleXMLElement $element The SimpleXMLElement object representing the <field /> tag for the form field object. 32 * @param mixed $value The form field value to validate. 33 * @param string|null $group The field name group control value. This acts as an array container for the field. 34 * For example if the field has name="foo" and the group value is set to "bar" then the 35 * full field name would end up being "bar[foo]". 36 * @param Registry|null $input An optional Registry object with the entire data set to validate against the entire form. 37 * @param Form|null $form The form object for which the field is being tested. 38 * 39 * @return boolean True if the value is valid, false otherwise. 40 */ 41 public function test(\SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null) 42 { 43 $filterInput = InputFilter::getInstance(); 44 45 if ( 46 preg_match('#[<>"\'%;()&\\\\]|\\.\\./#', $value) || strlen(utf8_decode($value)) < 2 47 || $filterInput->clean($value, 'TRIM') !== $value 48 || strlen(utf8_decode($value)) > $element['size'] 49 ) { 50 return false; 51 } 52 53 return true; 54 } 55 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |