FName::IsValidObjectName
#include "UObject/NameTypes.h"
Access: public
Specifiers: const
Description
Checks that this FName is a legal UObject name: non-empty, free of invalid characters, and within the maximum name length. Primarily used in editor tooling when the user renames an asset or object.
Caveats & Gotchas
- • NAME_None fails this check — validate against IsNone() separately if you need to distinguish 'no name set' from 'bad name'.
- • This is editor-focused validation. Shipping code that already controls its own FName construction does not need to call this, and doing so adds unnecessary overhead.
Signature
CORE_API bool IsValidObjectName( FText& OutReason ) const; Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| OutReason | FText& | If the check fails, receives a localised human-readable explanation of the failure. | — |
Return Type
bool Example
Gate a rename action on validity C++
FName NewName(*NewNameText.ToString());
FText FailReason;
if (NewName.IsValidObjectName(FailReason))
{
MyObject->Rename(*NewName.ToString());
}
else
{
UE_LOG(LogTemp, Warning, TEXT("Invalid name: %s"), *FailReason.ToString());
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?