23 lines
No EOL
899 B
C#
23 lines
No EOL
899 B
C#
using UnityEngine;
|
|
|
|
namespace Module.ProjectValidator.Editor
|
|
{
|
|
internal sealed class AttributeValidatorRange : IAttributeValidator<RangeAttribute>
|
|
{
|
|
public ValidatorResult Validate(RangeAttribute attribute, object value)
|
|
{
|
|
if (value is int iValue)
|
|
{
|
|
if (iValue < attribute.min || iValue > attribute.max)
|
|
return ValidatorResult.Create(EValidatorSeverity.Error, $"Value {iValue} is not in the range [{attribute.min};{attribute.max}]");
|
|
}
|
|
else if (value is float fValue)
|
|
{
|
|
if (fValue < attribute.min || fValue > attribute.max)
|
|
return ValidatorResult.Create(EValidatorSeverity.Error, $"Value {fValue} is not in the range [{attribute.min};{attribute.max}]");
|
|
}
|
|
|
|
return ValidatorResult.Valid;
|
|
}
|
|
}
|
|
} |