/// <inheritdoc />
        public void Validate(ValidationContext context)
        {
            IStructureValidator validator = _structureValidationFactory.CreateValidator(
                context.Country.TwoLetterISORegionName,
                context.Country.Iban.Structure
                );

            if (!validator.Validate(context.Value))
            {
                context.Result = IbanValidationResult.InvalidStructure;
            }
        }
Beispiel #2
0
        /// <inheritdoc />
        public ValidationRuleResult Validate(ValidationRuleContext context)
        {
            if (context.Country is null)
            {
                return(new InvalidStructureResult());
            }

            IStructureValidator validator = _structureValidationFactory.CreateValidator(
                context.Country.TwoLetterISORegionName,
                context.Country.Iban.Structure
                );

            return(validator.Validate(context.Value)
                ? ValidationRuleResult.Success
                : new InvalidStructureResult());
        }
Beispiel #3
0
        // ReSharper disable once InconsistentNaming
        public IStructureValidator CreateValidator(string twoLetterISORegionName, string structure)
        {
            string cacheKey = twoLetterISORegionName + "-" + structure;

            return(_cache.GetOrAdd(cacheKey, s => _innerFactory.CreateValidator(twoLetterISORegionName, structure)));
        }