WPCF7_SWV_MinLengthRule::validate()publicCF7 1.0

{} Это метод класса: WPCF7_SWV_MinLengthRule{}

Хуков нет.

Возвращает

null. Ничего.

Использование

$WPCF7_SWV_MinLengthRule = new WPCF7_SWV_MinLengthRule();
$WPCF7_SWV_MinLengthRule->validate( $context );
$context (обязательный)
-

Код WPCF7_SWV_MinLengthRule::validate() CF7 5.6.3

public function validate( $context ) {
	$field = $this->get_property( 'field' );
	$input = isset( $_POST[$field] ) ? $_POST[$field] : '';
	$input = wpcf7_array_flatten( $input );
	$input = wpcf7_exclude_blank( $input );

	if ( empty( $input ) ) {
		return true;
	}

	$total = 0;

	foreach ( $input as $i ) {
		$total += wpcf7_count_code_units( $i );
	}

	$threshold = (int) $this->get_property( 'threshold' );

	if ( $threshold <= $total ) {
		return true;
	} else {
		return new WP_Error( 'wpcf7_invalid_minlength',
			$this->get_property( 'error' )
		);
	}
}