AnsPress_Validation::comma_separted_count( string $field, string $param )

Description #

Count comma separated strings

Parameters #

  • $field
    string (Required)
  • $param
    string (Required)

Changelog #

VersionDescription
2.0Introduced.

Source #

File: includes/class/validation.php

	private function comma_separted_count($field, $param) {
		if ( isset( $this->fields[$field] ) ) {
			$tags = $this->fields[$field];

			if ( ! is_array( $tags ) ) {
				$tags = explode( ',', $tags );
			}

			if ( count( $tags ) < $param ) {
				$this->errors[$field] = sprintf( __( 'It must be minimum %d characters', 'anspress-question-answer' ), $param );
			}
		} elseif ( $param > 0 ) {
			$this->errors[$field] = sprintf( __( 'It must be minimum %d characters', 'anspress-question-answer' ), $param );
		}
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment