Code Duplication    Length = 9-14 lines in 3 locations

forms/CheckboxSetField.php 1 location

@@ 348-361 (lines=14) @@
345
				);
346
				return false;
347
			}
348
		} else {
349
			if (!in_array($this->value, $sourceArray)) {
350
				$validator->validationError(
351
					$this->name,
352
					_t(
353
						'CheckboxSetField.SOURCE_VALIDATION',
354
						"Please select a value within the list provided. '{value}' is not a valid option",
355
						array('value' => $this->value)
356
					),
357
					"validation"
358
				);
359
				return false;
360
			}
361
		}
362
		return true;
363
	}
364

forms/EmailField.php 1 location

@@ 47-55 (lines=9) @@
44
		// Escape delimiter characters.
45
		$safePattern = str_replace('/', '\\/', $pattern);
46
47
		if($this->value && !preg_match('/' . $safePattern . '/i', $this->value)) {
48
			$validator->validationError(
49
				$this->name,
50
				_t('EmailField.VALIDATION', 'Please enter an email address'),
51
				'validation'
52
			);
53
54
			return false;
55
		}
56
57
		return true;
58
	}

forms/ListboxField.php 1 location

@@ 309-322 (lines=14) @@
306
				);
307
				return false;
308
			}
309
		} else {
310
			if (!array_key_exists($this->value, $source)) {
311
				$validator->validationError(
312
					$this->name,
313
					_t(
314
						'ListboxField.SOURCE_VALIDATION',
315
						"Please select a value within the list provided. %s is not a valid option",
316
						array('value' => $this->value)
317
					),
318
					"validation"
319
				);
320
				return false;
321
			}
322
		}
323
		return true;
324
	}
325