Interface ValidatorFactory


  • public interface ValidatorFactory
    Creates built-in Validator instances and Validator instances loaded by name.
    • Method Detail

      • loadBuiltinValidators

        java.util.List<Validator> loadBuiltinValidators()
        Returns a list of built-in validators that are always applied to a Model regardless of if they are explicitly configured in the metadata of a model. This is in contrast to validators returns from calling createValidator(java.lang.String, software.amazon.smithy.model.node.ObjectNode), which are only applied to a model if they are declared in the metadata section of a model.
        Returns:
        Returns the loaded validators.
      • createValidator

        java.util.Optional<Validator> createValidator​(java.lang.String name,
                                                      ObjectNode configuration)
        Creates and configures a Validator by name.
        Parameters:
        name - Name of the validator to create.
        configuration - Configuration data used to create the validator.
        Returns:
        Returns the created validator wrapped in an Optional.
        Throws:
        SourceException - on configuration error.
        java.lang.RuntimeException - if an error occurs while creating.
      • createServiceFactory

        static ValidatorFactory createServiceFactory​(java.lang.Iterable<Validator> validators,
                                                     java.lang.Iterable<ValidatorService> services)
        Creates a ValidatorFactory that uses a collection of built-in validators and a collection of ValidatorService instances for configurable validators.

        The validators and services passed to this method are copied into a List before creating the actual factory to avoid holding on to ServiceLoader VM-wide instances that potentially utilize a Thread's context ClassLoader.

        Parameters:
        validators - Built-in validators to provide from the factory.
        services - ValidatorService instances to use to create validators.
        Returns:
        Returns the created ValidatorFactory.
      • createServiceFactory

        static ValidatorFactory createServiceFactory​(java.lang.ClassLoader classLoader)
        Creates a ValidatorFactory that discovers service providers using the given ClassLoader.
        Parameters:
        classLoader - Class loader used to find ValidatorProviders.
        Returns:
        Returns the created factory.