Automattic\WooCommerce\Blocks\Domain\Services

CheckoutFields::is_valid_fieldpublicWC 1.0

Validates a field against the given document object and context.

Метод класса: CheckoutFields{}

Хуков нет.

Возвращает

true|false|\WP_Error. True if the field is valid, a WP_Error otherwise.

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

$CheckoutFields = new CheckoutFields();
$CheckoutFields->is_valid_field( $field, $document_object );
$field(массив) (обязательный)
The field.
$document_object(DocumentObject|null)
The document object.
По умолчанию: null

Код CheckoutFields::is_valid_field() WC 11.0.1

public function is_valid_field( $field, $document_object = null ) {
	if ( $document_object && $this->contains_valid_rules( $field['validation'] ) ) {
		$field_schema = Validation::get_field_schema_with_context( $field['id'], $field['validation'], $document_object->get_context() );
		return Validation::validate_document_object( $document_object, $field_schema );
	}
	return true;
}