Validate::validate_array_max( 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_max( $field ) { $max_arr = (int) $field->get( 'array_max', 0 ); $value = $field->value(); if ( ! empty( $value ) && count( $value ) > $max_arr ) { $field->add_error( 'array-max', sprintf( // Translators: placeholder contain field label. __( 'Maximum values allowed in field %2$s is %1$d.', 'anspress-question-answer' ), $max_arr, $field->get( 'label' ) ) ); } }
Expand full source code Collapse full source code View on GitHub: lib/class-validate.php:538
Add your comment