MailPoet\EmailEditor\Validator\Schema

Number_Schema{}WC 1.0

Represents a schema for a number. See: https://developer.wordpress.org/rest-api/extending-the-rest-api/schema/#numbers

No Hooks.

Usage

$Number_Schema = new Number_Schema();
// use class methods

Methods

  1. public exclusiveMaximum( float $value )
  2. public exclusiveMinimum( float $value )
  3. public maximum( float $value )
  4. public minimum( float $value )
  5. public multipleOf( float $value )

Number_Schema{} code WC 9.8.1

class Number_Schema extends Schema {
	/**
	 * Schema definition.
	 *
	 * @var array
	 */
	protected $schema = array(
		'type' => 'number',
	);

	/**
	 * Sets the minimum value of the number.
	 *
	 * @param float $value Minimum value of the number.
	 */
	public function minimum( float $value ): self {
		return $this->update_schema_property( 'minimum', $value )
		->unset_schema_property( 'exclusiveMinimum' );
	}

	/**
	 * Sets the exclusiveMinimum property to true.
	 *
	 * @param float $value Minimum value of the number.
	 */
	public function exclusiveMinimum( float $value ): self {
		return $this->update_schema_property( 'minimum', $value )
		->update_schema_property( 'exclusiveMinimum', true );
	}

	/**
	 * Sets the maximum value of the number.
	 *
	 * @param float $value Maximum value of the number.
	 */
	public function maximum( float $value ): self {
		return $this->update_schema_property( 'maximum', $value )
		->unset_schema_property( 'exclusiveMaximum' );
	}

	/**
	 * Sets the exclusiveMaximum property to true.
	 *
	 * @param float $value Maximum value of the number.
	 */
	public function exclusiveMaximum( float $value ): self {
		return $this->update_schema_property( 'maximum', $value )
		->update_schema_property( 'exclusiveMaximum', true );
	}

	/**
	 * Sets the multipleOf property.
	 *
	 * @param float $value Multiple of the number.
	 */
	public function multipleOf( float $value ): self {
		return $this->update_schema_property( 'multipleOf', $value );
	}
}