public Mod(String Name, List <ModTitle> Titles, List <Release> Releases)
        {
            StringValidator.ValidateRequiredStringWithMaxLength(Name, nameof(Name), Mod.NameLength);
            ListValidator.ValidateRequiredListNotEmpty <ModTitle>(Titles, nameof(Titles));
            ListValidator.ValidateRequiredListNotEmpty <Release>(Releases, nameof(Releases));

            Regex modNameCaptureRegex = new Regex(Mod.ModNameCapturePattern);
            Match match = modNameCaptureRegex.Match(Name);

            if (!match.Success)
            {
                throw new ArgumentException($"Unable to parse \"{Name}\" to a valid mod name due to formatting.", "Name");
            }

            // TODO: Should we validate that the modName matches the various modName properties (e.g. ReleaseFileName.ModName, ReleaseDownloadURL.ModName, etc.)
            foreach (Release release in Releases)
            {
                if (release.ReleaseFileName.ModName != Name)
                {
                    throw new ArgumentException($"The mod name in the release filename \"{release.ReleaseFileName}\" does not match the specified mod name \"{Name}\".", nameof(Releases));
                }
                if (release.ReleaseDownloadUrl.ModName != Name.Replace(" ", "%20"))
                {
                    throw new ArgumentException($"The mod name in the release download URL \"{release.ReleaseDownloadUrl}\" does not match the specified mod name \"{Name}\".", nameof(Releases));
                }
            }

            this.Name     = match.Groups[1].Value;
            this.Releases = Releases.ConvertAll(release => new Release(release));
            this.Titles   = Titles.ConvertAll(title => new ModTitle(title));
        }
Beispiel #2
0
 public Heartbeat(ILogger <Heartbeat> logger, SqlService sql, GlobalInformation globalInformation, QuickSync quickSync, ListValidator listValidator)
 {
     _globalInformation = globalInformation;
     _sql           = sql;
     _logger        = logger;
     _quickSync     = quickSync;
     _listValidator = listValidator;
 }
Beispiel #3
0
        public bool should_validate_correctly(string address)
        {
            var validator = new ListValidator(
                new AuRaParameters.Validator()
            {
                Addresses = new[] { new Address(Include1), new Address(Include2), }
            });

            return(validator.IsValidSealer(new Address(address)));
        }
Beispiel #4
0
        public bool should_validate_correctly(string address, long index)
        {
            _logManager = Substitute.For <ILogManager>();
            var validator = new ListValidator(
                new AuRaParameters.Validator()
            {
                Addresses = new[] { new Address(Include1), new Address(Include2), }
            }, _logManager);

            return(validator.IsValidSealer(new Address(address), index));
        }
        private ListValidator GetListValidator(params Address[] address)
        {
            var logManager = Substitute.For <ILogManager>();
            var validator  = new ListValidator(
                new AuRaParameters.Validator()
            {
                ValidatorType = AuRaParameters.ValidatorType.List,
                Addresses     = address
            }, logManager);

            return(validator);
        }
        public Validator GetValidator()
        {
            Validator valiator = null;

            if (ListValidator.Count == 1)
            {
                valiator = ListValidator[0];
            }
            else
            if (CompositType == CompositaionType.AND)
            {
                valiator = new AndCompositeValidator(ListValidator.ToArray());
            }
            else
            if (CompositType == CompositaionType.OR)
            {
                valiator = new OrCompositeValidator(ListValidator.ToArray());
            }
            return(valiator);
        }
        public Release(DateTime ReleasedAt, String Sha1String, ReleaseDownloadUrl ReleaseDownloadUrl, ReleaseFileName ReleaseFileName, ModVersion ModVersion, FactorioVersion FactorioVersion, List <Dependency> Dependencies)
        {
            DateTimeValidator.ValidateRequiredDateTimeBeforePresent(ReleasedAt, nameof(ReleasedAt));
            ObjectValidator.ValidateRequiredObject(Sha1String, nameof(Sha1String));
            ObjectValidator.ValidateRequiredObject(ReleaseDownloadUrl, nameof(ReleaseDownloadUrl));
            ObjectValidator.ValidateRequiredObject(ReleaseFileName, nameof(ReleaseFileName));
            ObjectValidator.ValidateRequiredObject(ModVersion, nameof(ModVersion));
            ObjectValidator.ValidateRequiredObject(FactorioVersion, nameof(FactorioVersion));
            ListValidator.ValidateRequiredListNotEmpty(Dependencies, nameof(Dependencies));

            Regex sha1CaptureRegex = new Regex(Release.Sha1CapturePattern);
            Match match            = sha1CaptureRegex.Match(Sha1String);

            if (!match.Success)
            {
                throw new ArgumentException($"Unable to parse \"{Sha1String}\" to a valid SHA-1 hash due to formatting.", "Sha1String");
            }

            String sha1 = match.Groups[1].Value;

            if (sha1.Length != Sha1Length)
            {
                throw new ArgumentException($"Unable to parse \"{Sha1String}\" to a valid SHA-1 hash due to length. The SHA-1 hash must have a length of exactly {Release.Sha1Length} characters.", "Sha1String");
            }
            if (ModVersion != ReleaseFileName.ModVersion)
            {
                throw new ArgumentException("The specified release file name version does not match the specified release version.", "ReleaseFileName");
            }

            this.ReleasedAt         = ReleasedAt;
            this.ReleaseDownloadUrl = new ReleaseDownloadUrl(ReleaseDownloadUrl);
            this.ReleaseFileName    = new ReleaseFileName(ReleaseFileName);
            this.Sha1            = sha1;
            this.ModVersion      = new ModVersion(ModVersion);
            this.FactorioVersion = new FactorioVersion(FactorioVersion);
            // TODO: We may want to write an .AddDependency() method that validates that the dependency we're adding isn't for the release/mod itself. That would generate a circular dependency.
            this.Dependencies = Dependencies.ConvertAll(dependency => new Dependency(dependency));
        }
Beispiel #8
0
        private void buttonSubmit_Click(object sender, RoutedEventArgs e)
        {
            lv               = new ListValidator();
            creditCheck      = new CreditCard();
            phoneCheck       = new Phone();
            emailCheck       = new IsEmail();
            emailDocComCheck = new IsEmailExtension(new IsEmail());
            passwordCheck    = new IsPassword();

            creditCheck.check(textCreditCardName.Text, lNotify);
            phoneCheck.check(textPhoneNumber.Text, lNotify);
            emailCheck.check(textEmail.Text, lNotify);
            emailDocComCheck.check(textEmailDocCom.Text, lNotify);
            passwordCheck.check(pwbPassword.Password, lNotify);

            lv.AddValidator(creditCheck);
            lv.AddValidator(phoneCheck);
            lv.AddValidator(emailCheck);
            lv.AddValidator(emailDocComCheck);
            lv.AddValidator(passwordCheck);

            lv.SetShowBehavior(sb);
            lv.show();
        }
Beispiel #9
0
 public ListsStatus(ILogger <ListsStatus> logger, ListValidator validator)
 {
     _logger    = logger;
     _validator = validator;
 }
Beispiel #10
0
 public static bool IsValid(string value)
 {
     return(ListValidator.IsValid(value, "amb", "blu", "brn", "gry", "grn", "hzl", "oth"));
 }