private void ValidateValidatorParams() { if (string.IsNullOrWhiteSpace(Name)) { throw new InvalidOperationException($"ProtoCMS: validator name is required."); } if (!ContentType.VALID_ID_REGEX.IsMatch(Name)) { throw new InvalidOperationException( $"ProtoCMS: validator name must match regex '{ContentType.VALID_ID_PATTERN}'."); } if (HandledFormTypes == null || HandledFormTypes.Length == 0) { throw new InvalidOperationException( $"ProtoCMS: validator handled form types is required."); } foreach (var hft in HandledFormTypes) { if (!typeof(ContentModifierForm).IsAssignableFrom(hft)) { throw new InvalidOperationException($"ProtoCMS: validator's handled form type elements must all " + $"inherit from '{typeof(ContentModifierForm).FullName}' " + $"(problem type: '{hft}')."); } } if (ConfigType == null) { throw new InvalidOperationException($"ProtoCMS: validator config type is required."); } if (!typeof(ContentFieldValidatorConfiguration).IsAssignableFrom(ConfigType)) { throw new InvalidOperationException($"ProtoCMS: validator config type must be an instance of " + $"'{typeof(ContentFieldValidatorConfiguration).FullName}'."); } if (ConfigType.GetConstructor(Type.EmptyTypes) == null) { throw new InvalidOperationException($"ProtoCMS: validator config type must have a default " + $"parameterless constructor."); } }