protected override ValidationResult IsValid(object value, ValidationContext context)
        {
            var nationalIdentifier = value as string;

            if (_countryCode == null)
            {
                return(NationalIdentifierValidator.IsValidInAnyCountry(nationalIdentifier)
                    ? ValidationResult.Success
                    : new ValidationResult(ErrorMessages.GetInvalidIdentifierMessage(nationalIdentifier)));
            }

            var countryCode = (CountryCode)_countryCode;
            var validator   = NationalIdentifierValidator.GetValidator(countryCode);

            return(validator.IsValid(nationalIdentifier)
                ? ValidationResult.Success
                : new ValidationResult(
                       ErrorMessages.GetInvalidIdentifierMessage(nationalIdentifier, countryCode)));
        }
        public void GetValidator_Country_ReturnsCorrectValidator(CountryCode countryCode, Type type)
        {
            var result = NationalIdentifierValidator.GetValidator(countryCode);

            Assert.That(result, Is.AssignableFrom(type));
        }