Changeset 5758
- Timestamp:
- 10/30/07 08:14:50 (1 year ago)
- Files:
-
- branches/dwhittle/lib/validator/sfValidator.class.php (modified) (1 diff)
- branches/dwhittle/lib/validator/sfValidatorAll.class.php (modified) (1 diff)
- branches/dwhittle/lib/validator/sfValidatorAny.class.php (modified) (1 diff)
- branches/dwhittle/lib/validator/sfValidatorCallback.class.php (modified) (2 diffs)
- branches/dwhittle/lib/validator/sfValidatorChoice.class.php (modified) (3 diffs)
- branches/dwhittle/lib/validator/sfValidatorChoiceMany.class.php (modified) (2 diffs)
- branches/dwhittle/lib/validator/sfValidatorDecorator.class.php (modified) (1 diff)
- branches/dwhittle/lib/validator/sfValidatorEmail.class.php (modified) (1 diff)
- branches/dwhittle/lib/validator/sfValidatorFromDescription.class.php (copied) (copied from trunk/lib/validator/sfValidatorFromDescription.class.php)
- branches/dwhittle/lib/validator/sfValidatorRegex.class.php (modified) (2 diffs)
- branches/dwhittle/lib/validator/sfValidatorSchema.class.php (modified) (1 diff)
- branches/dwhittle/lib/validator/sfValidatorSchemaCompare.class.php (modified) (1 diff)
- branches/dwhittle/lib/validator/sfValidatorSchemaFilter.class.php (modified) (1 diff)
- branches/dwhittle/lib/validator/sfValidatorSchemaForEach.class.php (modified) (1 diff)
- branches/dwhittle/lib/validator/sfValidatorUrl.class.php (modified) (2 diffs)
- branches/dwhittle/test/unit/validator/sfValidatorAllTest.php (modified) (2 diffs)
- branches/dwhittle/test/unit/validator/sfValidatorAnyTest.php (modified) (2 diffs)
- branches/dwhittle/test/unit/validator/sfValidatorCallbackTest.php (modified) (3 diffs)
- branches/dwhittle/test/unit/validator/sfValidatorChoiceManyTest.php (modified) (1 diff)
- branches/dwhittle/test/unit/validator/sfValidatorChoiceTest.php (modified) (2 diffs)
- branches/dwhittle/test/unit/validator/sfValidatorFromDescriptionTest.php (copied) (copied from trunk/test/unit/validator/sfValidatorFromDescriptionTest.php)
- branches/dwhittle/test/unit/validator/sfValidatorRegexTest.php (modified) (2 diffs)
- branches/dwhittle/test/unit/validator/sfValidatorSchemaCompareTest.php (modified) (2 diffs)
- branches/dwhittle/test/unit/validator/sfValidatorTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dwhittle/lib/validator/sfValidator.class.php
r5651 r5758 273 273 { 274 274 } 275 276 /** 277 * Returns a string representation of this validator. 278 * 279 * @param integer Indentation (number of spaces before each line) 280 * 281 * @return string The string representation of the validator 282 */ 283 public function asString($indent = 0) 284 { 285 $options = $this->getOptionsWithoutDefaults(); 286 $messages = $this->getMessagesWithoutDefaults(); 287 288 return sprintf('%s%s(%s%s)', 289 str_repeat(' ', $indent), 290 str_replace('sfValidator', '', get_class($this)), 291 $options ? sfYamlInline::dump($options) : ($messages ? '{}' : ''), 292 $messages ? ', '.sfYamlInline::dump($messages) : '' 293 ); 294 } 295 296 /** 297 * Returns all options with non default values. 298 * 299 * @return string A string representation of the options 300 */ 301 protected function getOptionsWithoutDefaults() 302 { 303 $options = $this->options; 304 305 // remove default option values 306 $reflection = new ReflectionClass(get_class($this)); 307 $default = $reflection->newInstanceArgs(func_get_args()); 308 foreach ($default->getOptions() as $key => $value) 309 { 310 if (array_key_exists($key, $options) && $options[$key] === $value) 311 { 312 unset($options[$key]); 313 } 314 } 315 316 return $options; 317 } 318 319 /** 320 * Returns all error messages with non default values. 321 * 322 * @return string A string representation of the error messages 323 */ 324 protected function getMessagesWithoutDefaults() 325 { 326 $messages = $this->messages; 327 328 // remove default option values 329 $reflection = new ReflectionClass(get_class($this)); 330 $default = $reflection->newInstanceArgs(func_get_args()); 331 foreach ($default->getMessages() as $key => $value) 332 { 333 if (array_key_exists($key, $messages) && $messages[$key] === $value) 334 { 335 unset($messages[$key]); 336 } 337 } 338 339 return $messages; 340 } 275 341 } branches/dwhittle/lib/validator/sfValidatorAll.class.php
r5651 r5758 114 114 return $clean; 115 115 } 116 117 /** 118 * @see sfValidator 119 */ 120 public function asString($indent = 0) 121 { 122 $validators = ''; 123 for ($i = 0, $max = count($this->validators); $i < $max; $i++) 124 { 125 $validators .= "\n".$this->validators[$i]->asString($indent + 2)."\n"; 126 127 if ($i < $max - 1) 128 { 129 $validators .= str_repeat(' ', $indent + 2).'and'; 130 } 131 132 if ($i == $max - 2) 133 { 134 $options = $this->getOptionsWithoutDefaults(); 135 $messages = $this->getMessagesWithoutDefaults(); 136 137 if ($options || $messages) 138 { 139 $validators .= sprintf('(%s%s)', 140 $options ? sfYamlInline::dump($options) : ($messages ? '{}' : ''), 141 $messages ? ', '.sfYamlInline::dump($messages) : '' 142 ); 143 } 144 } 145 } 146 147 return sprintf("%s(%s%s)", 148 str_repeat(' ', $indent), 149 $validators, 150 str_repeat(' ', $indent) 151 ); 152 } 116 153 } branches/dwhittle/lib/validator/sfValidatorAny.class.php
r5651 r5758 108 108 throw new sfValidatorErrorSchema($this, $errors); 109 109 } 110 111 /** 112 * @see sfValidator 113 */ 114 public function asString($indent = 0) 115 { 116 $validators = ''; 117 for ($i = 0, $max = count($this->validators); $i < $max; $i++) 118 { 119 $validators .= "\n".$this->validators[$i]->asString($indent + 2)."\n"; 120 121 if ($i < $max - 1) 122 { 123 $validators .= str_repeat(' ', $indent + 2).'or'; 124 } 125 126 if ($i == $max - 2) 127 { 128 $options = $this->getOptionsWithoutDefaults(); 129 $messages = $this->getMessagesWithoutDefaults(); 130 131 if ($options || $messages) 132 { 133 $validators .= sprintf('(%s%s)', 134 $options ? sfYamlInline::dump($options) : ($messages ? '{}' : ''), 135 $messages ? ', '.sfYamlInline::dump($messages) : '' 136 ); 137 } 138 } 139 } 140 141 return sprintf("%s(%s%s)", 142 str_repeat(' ', $indent), 143 $validators, 144 str_repeat(' ', $indent) 145 ); 146 } 110 147 } branches/dwhittle/lib/validator/sfValidatorCallback.class.php
r5582 r5758 19 19 class sfValidatorCallback extends sfValidator 20 20 { 21 protected22 $callback = null;23 24 21 /** 25 22 * Constructor. 26 23 * 27 * The first argument can be any valid PHP callback.24 * Available options: 28 25 * 29 * @param mixed A PHP callback 30 * @param array An array of options 31 * @param array An array of error messages 26 * * callback: A valid PHP callback 32 27 * 33 28 * @see sfValidator 34 29 */ 35 public function __construct($ callback, $options = array(), $messages = array())30 public function __construct($options = array(), $messages = array()) 36 31 { 37 $this->callback = $callback; 32 if (!isset($options['callback'])) 33 { 34 throw new sfException('The "callback" option is mandatory.'); 35 } 38 36 39 37 parent::__construct($options, $messages); … … 53 51 protected function doClean($value) 54 52 { 55 return call_user_func($this->callback, $this, $value); 53 return call_user_func($this->getOption('callback'), $this, $value); 54 } 55 56 /** 57 * @see sfValidator 58 */ 59 protected function getOptionsWithoutDefaults() 60 { 61 return parent::getOptionsWithoutDefaults(array('callback' => array('--fake--'))); 62 } 63 64 /** 65 * @see sfValidator 66 */ 67 protected function getMessagesWithoutDefaults() 68 { 69 return parent::getMessagesWithoutDefaults(array('callback' => array('--fake--'))); 56 70 } 57 71 } branches/dwhittle/lib/validator/sfValidatorChoice.class.php
r5582 r5758 22 22 * Constructor. 23 23 * 24 * @param array An array of expected values25 * @param array An array of options26 * @param array An array of error messages24 * Available options: 25 * 26 * * choices: An array of expected values 27 27 * 28 28 * @see sfValidator 29 29 */ 30 public function __construct($ expected, $options = array(), $messages = array())30 public function __construct($options = array(), $messages = array()) 31 31 { 32 $options['expected'] = $expected; 32 if (!isset($options['choices'])) 33 { 34 throw new sfException('The "choices" option is mandatory.'); 35 } 33 36 34 37 parent::__construct($options, $messages); … … 40 43 protected function doClean($value) 41 44 { 42 if (!in_array($value, $this->getOption(' expected')))45 if (!in_array($value, $this->getOption('choices'))) 43 46 { 44 47 throw new sfValidatorError($this, 'invalid', array('value' => $value)); … … 47 50 return $value; 48 51 } 52 53 /** 54 * @see sfValidator 55 */ 56 protected function getOptionsWithoutDefaults() 57 { 58 return parent::getOptionsWithoutDefaults(array('choices' => array('--fake--'))); 59 } 60 61 /** 62 * @see sfValidator 63 */ 64 protected function getMessagesWithoutDefaults() 65 { 66 return parent::getMessagesWithoutDefaults(array('choices' => array('--fake--'))); 67 } 49 68 } branches/dwhittle/lib/validator/sfValidatorChoiceMany.class.php
r5582 r5758 17 17 * @version SVN: $Id$ 18 18 */ 19 class sfValidatorChoiceMany extends sfValidator 19 class sfValidatorChoiceMany extends sfValidatorChoice 20 20 { 21 /**22 * Constructor.23 *24 * @param array An array of expected values25 * @param array An array of options26 * @param array An array of error messages27 *28 * @see sfValidator29 */30 public function __construct($expected, $options = array(), $messages = array())31 {32 $options['expected'] = $expected;33 34 parent::__construct($options, $messages);35 }36 37 21 /** 38 22 * @see sfValidator … … 47 31 foreach ($values as $value) 48 32 { 49 if (!in_array($value, $this->getOption(' expected')))33 if (!in_array($value, $this->getOption('choices'))) 50 34 { 51 35 throw new sfValidatorError($this, 'invalid', array('value' => $value)); branches/dwhittle/lib/validator/sfValidatorDecorator.class.php
r5651 r5758 153 153 return $this->getValidator()->getErrorCodes(); 154 154 } 155 156 /** 157 * @see sfValidator 158 */ 159 public function asString($indent = 0) 160 { 161 return $this->getValidator()->asString($indent); 162 } 155 163 } branches/dwhittle/lib/validator/sfValidatorEmail.class.php
r5582 r5758 24 24 public function __construct($options = array(), $messages = array()) 25 25 { 26 parent::__construct('/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i', $options, $messages); 26 $options['pattern'] = '/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i'; 27 28 parent::__construct($options, $messages); 27 29 } 28 30 } branches/dwhittle/lib/validator/sfValidatorRegex.class.php
r5582 r5758 22 22 * Constructor. 23 23 * 24 * @param string A regex pattern compatible with PCRE25 * @param array An array of options26 * @param array An array of error messages24 * Available options: 25 * 26 * * pattern: A regex pattern compatible with PCRE 27 27 * 28 28 * @see sfValidator 29 29 */ 30 public function __construct($ pattern, $options = array(), $messages = array())30 public function __construct($options = array(), $messages = array()) 31 31 { 32 $options['pattern'] = $pattern; 32 if (!isset($options['pattern'])) 33 { 34 throw new sfException('The "pattern" option is mandatory.'); 35 } 33 36 34 37 parent::__construct($options, $messages); … … 49 52 return $clean; 50 53 } 54 55 /** 56 * @see sfValidator 57 */ 58 protected function getOptionsWithoutDefaults() 59 { 60 return parent::getOptionsWithoutDefaults(array('pattern' => array('--fake--'))); 61 } 62 63 /** 64 * @see sfValidator 65 */ 66 protected function getMessagesWithoutDefaults() 67 { 68 return parent::getMessagesWithoutDefaults(array('pattern' => array('--fake--'))); 69 } 51 70 } branches/dwhittle/lib/validator/sfValidatorSchema.class.php
r5651 r5758 256 256 return $this->fields; 257 257 } 258 259 /** 260 * @see sfValidator 261 */ 262 public function asString($indent = 0) 263 { 264 throw new sfException('Unable to convert a sfValidatorSchema to string.'); 265 } 258 266 } branches/dwhittle/lib/validator/sfValidatorSchemaCompare.class.php
r5582 r5758 105 105 if (!$valid) 106 106 { 107 throw new sfValidatorError($this, 'invalid', array('value' => $values)); 107 throw new sfValidatorError($this, 'invalid', array( 108 'left_field' => $leftValue, 109 'right_field' => $rightValue, 110 'operator' => $this->getOption('operator'), 111 )); 108 112 } 109 113 110 114 return $values; 111 115 } 116 117 /** 118 * @see sfValidator 119 */ 120 public function asString($indent = 0) 121 { 122 $options = $this->getOptionsWithoutDefaults('--fake--', '--', '--fake--'); 123 $messages = $this->getMessagesWithoutDefaults('--fake--', '--', '--fake--'); 124 unset($options['leftField'], $options['operator'], $options['rightField']); 125 126 $arguments = ''; 127 if ($options || $messages) 128 { 129 $arguments = sprintf('(%s%s)', 130 $options ? sfYamlInline::dump($options) : ($messages ? '{}' : ''), 131 $messages ? ', '.sfYamlInline::dump($messages) : '' 132 ); 133 } 134 135 return sprintf('%s%s %s%s %s', 136 str_repeat(' ', $indent), 137 $this->getOption('leftField'), 138 $this->getOption('operator'), 139 $arguments, 140 $this->getOption('rightField') 141 ); 142 } 112 143 } branches/dwhittle/lib/validator/sfValidatorSchemaFilter.class.php
r5651 r5758 66 66 return $values; 67 67 } 68 69 /** 70 * @see sfValidator 71 */ 72 public function asString($indent = 0) 73 { 74 return sprintf('%s%s:%s', str_repeat(' ', $indent), $this->getOption('field'), $this->getOption('validator')->asString(0)); 75 } 68 76 } branches/dwhittle/lib/validator/sfValidatorSchemaForEach.class.php
r5582 r5758 41 41 parent::__construct($fields, $options, $messages); 42 42 } 43 44 /** 45 * @see sfValidator 46 */ 47 public function asString($indent = 0) 48 { 49 throw new sfException('Unable to convert a sfValidatorSchemaForEach to string.'); 50 } 43 51 } branches/dwhittle/lib/validator/sfValidatorUrl.class.php
r5582 r5758 24 24 public function __construct($options = array(), $messages = array()) 25 25 { 26 $ pattern= '~^26 $options['pattern'] = '~^ 27 27 https?:// # http or https 28 28 ( … … 35 35 $~ix'; 36 36 37 parent::__construct($ pattern, $options, $messages);37 parent::__construct($options, $messages); 38 38 } 39 39 } branches/dwhittle/test/unit/validator/sfValidatorAllTest.php
r5651 r5758 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(1 4, new lime_output_color());13 $t = new lime_test(16, new lime_output_color()); 14 14 15 15 $v1 = new sfValidatorString(array('max_length' => 3)); … … 86 86 $t->is(!$e instanceof sfValidatorErrorSchema, 'max_length', '->clean() throws a sfValidatorError if invalid message is not empty'); 87 87 } 88 89 // ->asString() 90 $t->diag('->asString()'); 91 $v1 = new sfValidatorString(array('max_length' => 3)); 92 $v2 = new sfValidatorString(array('min_length' => 3)); 93 $v = new sfValidatorAll(array($v1, $v2)); 94 $t->is($v->asString(), <<<EOF 95 ( 96 String({ max_length: 3 }) 97 and 98 String({ min_length: 3 }) 99 ) 100 EOF 101 , '->asString() returns a string representation of the validator'); 102 103 $v = new sfValidatorAll(array($v1, $v2), array(), array('required' => 'This is required.')); 104 $t->is($v->asString(), <<<EOF 105 ( 106 String({ max_length: 3 }) 107 and({}, { required: 'This is required.' }) 108 String({ min_length: 3 }) 109 ) 110 EOF 111 , '->asString() returns a string representation of the validator'); branches/dwhittle/test/unit/validator/sfValidatorAnyTest.php
r5651 r5758 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(1 6, new lime_output_color());13 $t = new lime_test(18, new lime_output_color()); 14 14 15 15 $v1 = new sfValidatorString(array('max_length' => 3)); … … 92 92 $v2->setOption('min_length', 1); 93 93 $t->is($v->clean('foo'), 'foo', '->clean() returns the string unmodified'); 94 95 // ->asString() 96 $t->diag('->asString()'); 97 $v1 = new sfValidatorString(array('max_length' => 3)); 98 $v2 = new sfValidatorString(array('min_length' => 3)); 99 $v = new sfValidatorAny(array($v1, $v2)); 100 $t->is($v->asString(), <<<EOF 101 ( 102 String({ max_length: 3 }) 103 or 104 String({ min_length: 3 }) 105 ) 106 EOF 107 , '->asString() returns a string representation of the validator'); 108 109 $v = new sfValidatorAny(array($v1, $v2), array(), array('required' => 'This is required.')); 110 $t->is($v->asString(), <<<EOF 111 ( 112 String({ max_length: 3 }) 113 or({}, { required: 'This is required.' }) 114 String({ min_length: 3 }) 115 ) 116 EOF 117 , '->asString() returns a string representation of the validator'); branches/dwhittle/test/unit/validator/sfValidatorCallbackTest.php
r5582 r5758 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test( 3, new lime_output_color());13 $t = new lime_test(5, new lime_output_color()); 14 14 15 15 function clean_test($validator, $value) … … 23 23 } 24 24 25 $v = new sfValidatorCallback('clean_test'); 25 // __construct() 26 $t->diag('__construct()'); 27 try 28 { 29 new sfValidatorCallback(); 30 $t->fail('__construct() throws an sfException if you don\'t pass a callback option'); 31 } 32 catch (sfException $e) 33 { 34 $t->pass('__construct() throws an sfException if you don\'t pass a callback option'); 35 } 36 37 $v = new sfValidatorCallback(array('callback' => 'clean_test')); 26 38 27 39 // ->clean() … … 41 53 $t->diag('->configure()'); 42 54 $t->is($v->clean(''), null, '->configure() switch required to false by default'); 55 56 // ->asString() 57 $t->diag('->asString()'); 58 $t->is($v->asString(), 'Callback({ callback: clean_test })', '->asString() returns a string representation of the validator'); branches/dwhittle/test/unit/validator/sfValidatorChoiceManyTest.php
r5582 r5758 13 13 $t = new lime_test(5, new lime_output_color()); 14 14 15 $v = new sfValidatorChoiceMany(array(' foo', 'bar'));15 $v = new sfValidatorChoiceMany(array('choices' => array('foo', 'bar'))); 16 16 17 17 // ->clean() branches/dwhittle/test/unit/validator/sfValidatorChoiceTest.php
r5582 r5758 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test( 3, new lime_output_color());13 $t = new lime_test(5, new lime_output_color()); 14 14 15 $v = new sfValidatorChoice(array('foo', 'bar')); 15 // __construct() 16 $t->diag('__construct()'); 17 try 18 { 19 new sfValidatorChoice(); 20 $t->fail('__construct() throws an sfException if you don\'t pass an expected option'); 21 } 22 catch (sfException $e) 23 { 24 $t->pass('__construct() throws an sfException if you don\'t pass an expected option'); 25 } 26 27 $v = new sfValidatorChoice(array('choices' => array('foo', 'bar'))); 16 28 17 29 // ->clean() … … 29 41 $t->pass('->clean() throws an sfValidatorError if the value is not an expected value'); 30 42 } 43 44 // ->asString() 45 $t->diag('->asString()'); 46 $t->is($v->asString(), 'Choice({ choices: [foo, bar] })', '->asString() returns a string representation of the validator'); branches/dwhittle/test/unit/validator/sfValidatorRegexTest.php
r5582 r5758 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test( 3, new lime_output_color());13 $t = new lime_test(5, new lime_output_color()); 14 14 15 $v = new sfValidatorRegex('/^[0-9]+$/'); 15 // __construct() 16 $t->diag('__construct()'); 17 try 18 { 19 new sfValidatorRegex(); 20 $t->fail('__construct() throws an sfException if you don\'t pass a pattern option'); 21 } 22 catch (sfException $e) 23 { 24 $t->pass('__construct() throws an sfException if you don\'t pass a pattern option'); 25 } 26 27 $v = new sfValidatorRegex(array('pattern' => '/^[0-9]+$/')); 16 28 17 29 // ->getErrorCodes() … … 32 44 $t->pass('->clean() throws an sfValidatorError if the value does not match the pattern'); 33 45 } 46 47 // ->asString() 48 $t->diag('->asString()'); 49 $t->is($v->asString(), 'Regex({ pattern: \'/^[0-9]+$/\' })', '->asString() returns a string representation of the validator'); branches/dwhittle/test/unit/validator/sfValidatorSchemaCompareTest.php
r5582 r5758 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(1 7, new lime_output_color());13 $t = new lime_test(19, new lime_output_color()); 14 14 15 15 $v = new sfValidatorSchemaCompare('left', sfValidatorSchemaCompare::EQUAL, 'right'); … … 65 65 $t->pass('->clean() throws an sfException exception if the first argument is not an array of value'); 66 66 } 67 68 // ->asString() 69 $t->diag('->asString()'); 70 $v = new sfValidatorSchemaCompare('left', '==', 'right'); 71 $t->is($v->asString(), 'left == right', '->asString() returns a string representation of the validator'); 72 73 $v = new sfValidatorSchemaCompare('left', '==', 'right', array(), array('required' => 'This is required.')); 74 $t->is($v->asString(), 'left ==({}, { required: \'This is required.\' }) right', '->asString() returns a string representation of the validator'); branches/dwhittle/test/unit/validator/sfValidatorTest.php
r5651 r5758 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(2 3, new lime_output_color());13 $t = new lime_test(27, new lime_output_color()); 14 14 15 15 class ValidatorIdentity extends sfValidator … … 121 121 sfValidator::setCharset('ISO-8859-1'); 122 122 $t->is(sfValidator::getCharset(), 'ISO-8859-1', '::setCharset() changes the charset to use for validators'); 123 124 // ->asString() 125 $t->diag('->asString()'); 126 $v = new ValidatorIdentity(); 127 $t->is($v->asString(), 'ValidatorIdentity()', '->asString() returns a string representation of the validator'); 128 $v->setOption('required', false); 129 $v->setOption('foo', 'foo'); 130 $t->is($v->asString(), 'ValidatorIdentity({ required: false, foo: foo })', '->asString() returns a string representation of the validator'); 131 132 $v->setMessage('required', 'This is required.'); 133 $t->is($v->asString(), 'ValidatorIdentity({ required: false, foo: foo }, { required: \'This is required.\' })', '->asString() returns a string representation of the validator'); 134 135 $v = new ValidatorIdentity(); 136 $v->setMessage('required', 'This is required.'); 137 $t->is($v->asString(), 'ValidatorIdentity({}, { required: \'This is required.\' })', '->asString() returns a string representation of the validator');