Validate::validate_required( object $field )

Description #

Validate required field.

Parameters #

  • $field
    object (Required) Instance of @see AP_Field object.

Source #

File: lib/class-validate.php

	public static function validate_required( $field ) {
		if ( '' === $field->value() || is_null( $field->value() ) ) {
			$field->add_error(
				'required',
				sprintf(
					// Translators: placeholder contain field label.
					__( '%s field is required.', 'anspress-question-answer' ),
					$field->get( 'label' )
				)
			);
		}
	}

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