# Data Asset: Only allow an int var to be positive

**URL:** <https://forums.unrealengine.com/t/data-asset-only-allow-an-int-var-to-be-positive/2847976>\
**Category:** C++\
**Tags:** unreal-engine, question, CPP\
**Created:** [October 31, 2026, 5:25pm UTC](https://forums.unrealengine.com/t/data-asset-only-allow-an-int-var-to-be-positive/2847976 "2026-10-31T17:25:17Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Extrone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/extrone/32/906554_2.png) [@Extrone](https://forums.unrealengine.com/u/Extrone)\
**Post date:** [October 31, 2026, 5:47pm UTC](https://forums.unrealengine.com/t/data-asset-only-allow-an-int-var-to-be-positive/2847976/2 "2026-10-31T17:47:44Z")

</div>

If you’re trying to limit the value of NumPages to only positive values while modifying it in the edttor, you can use the meta property `ClampMin` to set a minimum value.

```auto
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta=(ClampMin=0))
int32 NumPages = 100;

```

> **[Clamp Min - All UPROPERTY Specifiers](https://unreal-garden.com/docs/uproperty/#clampmin)**
>
> Unreal's Property Specifiers page lists all of the core specifiers and many of the metadata specifiers, but it is not an exhaustive list. | Sample code, screenshots and comments for all specifiers, including undocumented ones.

* * *

There’s also the `PostEditChangeProperty` function that you can override to do operations on the value after it was edited.

```h
#if WITH_EDITOR
void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
#endif

```

```c++
#if WITH_EDITOR
void ASomeActor::PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent)
{
  Super::PostEditChangeProperty(PropertyChangedEvent);

  FName PropertyName = (PropertyChangedEvent.Property != NULL) ? PropertyChangedEvent.Property->GetFName() : NAME_None;
  if (PropertyName == GET_MEMBER_NAME_CHECKED(ASomeActor, NumPages)) 
  {
    if (NumPages < 0) 
    {
        MakePositive();
    }
  }
}
#endif

```

^ modified code from:

> [@How do I use PostEditChangeProperty?](https://forums.unrealengine.com/t/how-do-i-use-posteditchangeproperty/324110/2):
>
> /\* If MyBool belongs to the ASomeActor \*/ void ASomeActor::PostEditChangeProperty(struct FPropertyChangedEvent& e) { Super::PostEditChangeProperty(e); FName PropertyName = (e.Property != NULL) ? e.Property-\>GetFName() : NAME\_None; if (PropertyName == GET\_MEMBER\_NAME\_CHECKED(ASomeActor, MyBool)) { /\* Because you are inside the class, you should see the value already changed \*/ if (MyBool) doThings(); // This is how you access MyBool. els…

---

_[View the full topic](https://forums.unrealengine.com/t/data-asset-only-allow-an-int-var-to-be-positive/2847976)._
