src/objects/ExtensibleSearchSuggestion.php
public function validate() {

		$result = parent::validate();

		// Confirm that the current search suggestion matches the minimum autocomplete length and doesn't already exist.

		if($result->isValid() && (strlen($this->Term) < 3)) {
			$result->addError('Minimum autocomplete length required!');
		}
		else if($result->isValid() && ExtensibleSearchSuggestion::get_one(ExtensibleSearchSuggestion::class, array(
			'ID != ?' => (int)$this->ID,
			'Term = ?' => $this->Term,
			'ExtensibleSearchPageID = ?' => $this->ExtensibleSearchPageID
		))) {
			$result->addError('Suggestion already exists!');
		}

		// Allow extension customisation.

		$this->extend('validateExtensibleSearchSuggestion', $result);
		return $result;
	}
public function validate() {

		$result = parent::validate();

		// Confirm that the current search suggestion matches the minimum autocomplete length and doesn't already exist.

		if($result->isValid() && (strlen($this->Term) < 3)) {
			$result->addError('Minimum autocomplete length required!');
		}
		else if($result->isValid() && ExtensibleSearchSuggestion::get_one(ExtensibleSearchSuggestion::class, array(
			'ID != ?' => (int)$this->ID,
			'Term = ?' => $this->Term,
			'ExtensibleSearchPageID = ?' => $this->ExtensibleSearchPageID
		))) {
			$result->addError('Suggestion already exists!');
		}

		// Allow extension customisation.

		$this->extend('validateExtensibleSearchSuggestion', $result);
		return $result;
	}
public function validate ( ) { $ result = parent :: validate ( ) ; // Confirm that the current search suggestion matches the minimum autocomplete length and doesn't already exist. if ( $ result -> isValid ( ) && ( strlen ( $ this -> Term ) < 3 ) ) { $ result -> addError ( 'Minimum autocomplete length required!' ) ; } else if ( $ result -> isValid ( ) && ExtensibleSearchSuggestion :: get_one ( ExtensibleSearchSuggestion :: class , array ( 'ID != ?' => ( int ) $ this -> ID , 'Term = ?' => $ this -> Term , 'ExtensibleSearchPageID = ?' => $ this -> ExtensibleSearchPageID ) ) ) { $ result -> addError ( 'Suggestion already exists!' ) ; } // Allow extension customisation. $ this -> extend ( 'validateExtensibleSearchSuggestion' , $ result ) ; return $ result ; }
Confirm that the current search suggestion is valid.
Confirm that the current search suggestion is valid .