Validate::validate_array_min( object $field )
Description #
Validate if there are minimum items in an array.
Parameters #
- $fieldobject (Required) Instance of @see
AP_Field
object.
Source #
File: lib/class-validate.php
public static function validate_array_min( $field ) { $min_arr = $field->get( 'array_min', 0 ); $value = $field->value(); if ( $min_arr > 0 && ( empty( $value ) || ! is_array( $value ) || $min_arr > count( $value ) ) ) { $field->add_error( 'array-min', sprintf( // Translators: placeholder contain field label. __( 'Minimum %1$d values are required in field %2$s.', 'anspress-question-answer' ), $min_arr, $field->get( 'label' ) ) ); } }
Expand full source code Collapse full source code View on GitHub: lib/class-validate.php:515
Add your comment