RealDocs

FName::IsValidXName

function Core Since 4.0
#include "UObject/NameTypes.h"
Access: public Specifiers: static

Description

Validates that a name does not contain any of the specified forbidden characters. Used internally by IsValidObjectName and IsValidGroupName, and directly in editor tooling to check user-supplied names against custom character sets.

Caveats & Gotchas

  • The instance method overload `IsValidXName(const FString& InInvalidChars, FText* OutReason) const` simply delegates to this static version — prefer the static form when the name is not yet stored as an FName.
  • The zero-argument overload `IsValidXName() const` uses INVALID_NAME_CHARACTERS as the forbidden set and is suitable for quick sanity checks, but callers that need context-specific rules (e.g. package vs. object naming) should call IsValidObjectName or IsValidGroupName instead.

Signature

CORE_API static bool IsValidXName( const FName InName, const FString& InInvalidChars, FText* OutReason = nullptr, const FText* InErrorCtx = nullptr );

Parameters

Name Type Description Default
InName const FName The name to validate.
InInvalidChars const FString& A string containing every character that is not permitted in the name.
OutReason FText* If non-null and the check fails, receives a localised error message explaining why. nullptr
InErrorCtx const FText* Optional context label shown in the error message (defaults to 'Name'). nullptr

Return Type

bool

Example

Validate a user-supplied actor name C++
FText Reason;
FString InvalidChars = INVALID_NAME_CHARACTERS;
FName Candidate(*UserInputString);
if (!FName::IsValidXName(Candidate, InvalidChars, &Reason))
{
    FMessageDialog::Open(EAppMsgType::Ok, Reason);
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.