UPROPERTY check value range

I have a property for an offset.
This property is accessible from the BP Editor

Apparently the only integer value writable within the BP Editor is int32 and uint8.
This value must be positive 0 to n.

Unfortunately, uint8 is too short. Therefore I set it as int32.

What I need to do is to check, within the BP Editor, that value still positive.
I cannot found a way to trap the event when the value change or a method to validate the input.

/**
	<summary>The x position of debug info</summary>
	*/
	UPROPERTY(EditDefaultsOnly, meta = (EditCondition = "DisplayDebugInfo"), Category = Display)
	int32  OffsetX;

	/**
	<summary>The y position of debug info</summary>
	*/
	UPROPERTY(EditDefaultsOnly, meta = (EditCondition = "DisplayDebugInfo"), Category = Display)
	int32  OffsetY;

My question is :
how to check the value to remains positive even if the user type -300.
and also how to set back a 0 value when it goes below 0.

Txs for your help.
D.

I can’t check the exact wording right now but there should be examples of the use of meta keywords in properties like clampmin and clampmax. These will allow you to specify limits that the editor will enforce.

You can use that in meta :

///Specifies the lowest that the value slider should represent.
UIMin

///Specifies the highest that the value slider should represent.
UIMax

///Specifies the minimum value that may be entered for the property.
ClampMin

///Specifies the maximum value that may be entered for the property.
ClampMax

An example of it’s useage:

UPROPERTY(EditAnywhere, Category = "Test", meta=(ClampMin = "0.0", ClampMax = "300.0", UIMin = "0.0", UIMax = "300.0"))
	float mMyValue;
5 Likes

Thank your very much for your help !!!

D.

The proper way to accept an answer it to actually accept it from the one that gave it to you :wink: Be it Matthew or me.