using InfinityPBR.ModularCharacterHelper;
using Sirenix.OdinInspector.Editor.Validation;
using VOID.Editor.AttributeValidator;

[assembly: RegisterValidator(typeof(ModularPartValidator))]

namespace VOID.Editor.AttributeValidator
{
    public class ModularPartValidator : ValueValidator<ModularPart>
    {
        protected override void Validate(ValidationResult result)
        {
            if (Value == null) return;
            
            ValidateBoneRoot(result);
            ValidateSkinnedRenderer(result);
        }

        private void ValidateBoneRoot(ValidationResult result)
        {
            if (Value.boneRoot) return;
            
            result.AddError($"<b>{nameof(Value.boneRoot)}</b> is required!");
        }

        private void ValidateSkinnedRenderer(ValidationResult result)
        {
            if (Value.skinnedMeshRenderer) return;
            
            result.AddError($"<b>{nameof(Value.skinnedMeshRenderer)}</b> is required!");
        }
    }
}