llms_rest_validate_positive_float( integer $number, boolean $include_zero = true )

Validate strict positive float number


Parameters Parameters

$number

(integer) (Required) Float number to validate.

$include_zero

(boolean) (Optional) Whether or not 0 is included. Default is true.

Default value: true


Top ↑

Return Return

(boolean)


Top ↑

Source Source

File: libraries/lifterlms-rest/includes/server/llms-rest-server-functions.php

function llms_rest_validate_positive_float( $number, $include_zero = true ) {
	// @TODO min_range and max_range options for FILTER_VALIDATE_FLOAT are only available since PHP 7.4.
	$is_float = false !== filter_var( (float) $number, FILTER_VALIDATE_FLOAT );
	return $is_float && ( $include_zero ? $number >= 0 : $number > 0 );
}


Top ↑

Changelog Changelog

Changelog
Version Description
[versoin] Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.