using System.Collections.Generic;
using Valg.EVA.Skanning.Scan.ReadSoftContracts.Model;
using Valg.EVA.Skanning.ServicesModel.Internal.Validation;

namespace Valg.Eva.Skanning.Scan.Presentation.ReadSoftModel.FieldValidators
{
    public class MarkIncrFieldValidator : IFieldValidator
    {
        private readonly FillPercentageRangeChecker rangeChecker;

        public MarkIncrFieldValidator(FillPercentageRangeCheckerFactory rangeCheckerFactory)
        {
            rangeChecker = rangeCheckerFactory.GetPersonVoteRangeChecker();
        }

        public ScannableFieldType FieldType { get { return ScannableFieldType.MarkIncr; } }
        public bool IsFieldValid(ScannedField field, IEnumerable<ScannedField> alreadyAddedFields)
        {
            return IsMarkIncrValid(int.Parse(field.Value));
        }

        private bool IsMarkIncrValid(int fillPercentage)
        {
            return rangeChecker.IsInsideRange(fillPercentage);
        }

    }
}
