MCPcopy Create free account
hub / github.com/MothCocoon/FlowGraph / ValidateAsset

Method ValidateAsset

Source/Flow/Private/FlowAsset.cpp:246–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

244}
245
246EDataValidationResult UFlowAsset::ValidateAsset(FFlowMessageLog& MessageLog)
247{
248 // validate nodes
249 for (const TPair<FGuid, UFlowNode*>& Node : ObjectPtrDecay(Nodes))
250 {
251 if (IsValid(Node.Value))
252 {
253 FText FailureReason;
254 if (!IsNodeOrAddOnClassAllowed(Node.Value->GetClass(), &FailureReason))
255 {
256 const FString ErrorMsg =
257 FailureReason.IsEmpty()
258 ? FString::Format(*ValidationError_NodeClassNotAllowed, {*Node.Value->GetClass()->GetName()})
259 : FailureReason.ToString();
260
261 MessageLog.Error(*ErrorMsg, Node.Value);
262 }
263
264 Node.Value->ValidationLog.Messages.Empty();
265 Node.Value->ValidateNode();
266 MessageLog.Messages.Append(Node.Value->ValidationLog.Messages);
267
268 // Validate AddOns
269 for (UFlowNodeAddOn* AddOn : Node.Value->GetFlowNodeAddOnChildren())
270 {
271 if (IsValid(AddOn))
272 {
273 ValidateAddOnTree(*AddOn, MessageLog);
274 }
275 else
276 {
277 const FString ErrorMsg = FString::Format(*ValidationError_NullAddOnNodeInstance, {*Node.Key.ToString()});
278 MessageLog.Error(*ErrorMsg, this);
279 }
280 }
281 }
282 else
283 {
284 const FString ErrorMsg = FString::Format(*ValidationError_NullNodeInstance, {*Node.Key.ToString()});
285 MessageLog.Error(*ErrorMsg, this);
286 }
287 }
288
289 // if at least one error has been has been logged : mark the asset as invalid
290 for (const TSharedRef<FTokenizedMessage>& Msg : MessageLog.Messages)
291 {
292 if (Msg->GetSeverity() == EMessageSeverity::Error)
293 {
294 return EDataValidationResult::Invalid;
295 }
296 }
297
298 // otherwise, the asset is considered valid (even with warnings or notes)
299 return EDataValidationResult::Valid;
300}
301
302bool UFlowAsset::IsNodeOrAddOnClassAllowed(const UClass* FlowNodeOrAddOnClass, FText* OutOptionalFailureReason) const
303{

Callers

nothing calls this directly

Calls 5

IsValidFunction · 0.85
IsEmptyMethod · 0.80
ToStringMethod · 0.80
GetNameMethod · 0.45
ValidateNodeMethod · 0.45

Tested by

no test coverage detected