---
apiVersion: v1
kind: ConfigMap
metadata:
  labels:
    funktion.fabric8.io/kind: Connector
  name: bean-validator
data:
  deployment.yml: |
    ---
    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
      labels:
        funktion.fabric8.io/kind: Subscription
        connector: bean-validator
    spec:
      replicas: 1
      template:
        metadata:
          labels:
            funktion.fabric8.io/kind: Subscription
            connector: bean-validator
        spec:
          containers:
          - image: funktion/connector-bean-validator:${project.version}
            name: connector
  schema.yml: |
    ---
    component:
      kind: component
      scheme: bean-validator
      syntax: bean-validator:label
      title: Bean Validator
      description: The Validator component performs bean validation of the message body using the Java Bean Validation API.
      label: validation
      deprecated: false
      async: false
      producerOnly: true
      javaType: org.apache.camel.component.bean.validator.BeanValidatorComponent
      groupId: org.apache.camel
      artifactId: camel-bean-validator
      version: 2.18.3
    componentProperties: {}
    properties:
      label:
        kind: path
        group: producer
        required: true
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        description: Where label is an arbitrary text value describing the endpoint
        order: 0
      constraintValidatorFactory:
        kind: parameter
        group: producer
        type: object
        javaType: javax.validation.ConstraintValidatorFactory
        deprecated: false
        secret: false
        description: To use a custom ConstraintValidatorFactory
        order: 1
      group:
        kind: parameter
        group: producer
        type: string
        javaType: java.lang.String
        deprecated: false
        secret: false
        defaultValue: javax.validation.groups.Default
        description: To use a custom validation group
        order: 2
      messageInterpolator:
        kind: parameter
        group: producer
        type: object
        javaType: javax.validation.MessageInterpolator
        deprecated: false
        secret: false
        description: To use a custom MessageInterpolator
        order: 3
      traversableResolver:
        kind: parameter
        group: producer
        type: object
        javaType: javax.validation.TraversableResolver
        deprecated: false
        secret: false
        description: To use a custom TraversableResolver
        order: 4
      validationProviderResolver:
        kind: parameter
        group: producer
        type: object
        javaType: javax.validation.ValidationProviderResolver
        deprecated: false
        secret: false
        description: To use a a custom ValidationProviderResolver
        order: 5
      synchronous:
        kind: parameter
        group: advanced
        label: advanced
        type: boolean
        javaType: boolean
        deprecated: false
        secret: false
        defaultValue: false
        description: Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported).
        order: 6
  documentation.adoc: "[[BeanValidator-BeanValidatorComponent]]\nBean Validator Component\n\
    ~~~~~~~~~~~~~~~~~~~~~~~~\n\n*Available as of Camel 2.3*\n\nThe Validator component\
    \ performs bean validation of the message body\nusing the Java Bean Validation\
    \ API\n(http://jcp.org/en/jsr/detail?id=303[JSR 303]). Camel uses the reference\n\
    implementation, which is\nhttp://docs.jboss.org/hibernate/validator/4.3/reference/en-US/html_single/[Hibernate\n\
    Validator].\n\nMaven users will need to add the following dependency to their\
    \ `pom.xml`\nfor this component:\n\n[source,xml]\n------------------------------------------------------------\n\
    <dependency>\n    <groupId>org.apache.camel</groupId>\n    <artifactId>camel-bean-validator</artifactId>\n\
    \    <version>x.y.z</version>\n    <!-- use the same version as your Camel core\
    \ version -->\n</dependency>\n------------------------------------------------------------\n\
    \n[[BeanValidator-URIformat]]\nURI format\n^^^^^^^^^^\n\n[source,java]\n------------------------------\n\
    bean-validator:label[?options]\n------------------------------\n\nor\n\n[source,java]\n\
    --------------------------------\nbean-validator://label[?options]\n--------------------------------\n\
    \nWhere *label* is an arbitrary text value describing the endpoint. +\n You can\
    \ append query options to the URI in the following format,\n?option=value&option=value&...\n\
    \n[[BeanValidator-URIOptions]]\nURI Options\n^^^^^^^^^^^\n\n\n// component options:\
    \ START\nThe Bean Validator component has no options.\n// component options: END\n\
    \n\n\n// endpoint options: START\nThe Bean Validator component supports 7 endpoint\
    \ options which are listed below:\n\n{% raw %}\n[width=\"100%\",cols=\"2,1,1m,1m,5\"\
    ,options=\"header\"]\n|=======================================================================\n\
    | Name | Group | Default | Java Type | Description\n| label | producer |  | String\
    \ | *Required* Where label is an arbitrary text value describing the endpoint\n\
    | constraintValidatorFactory | producer |  | ConstraintValidatorFactory | To use\
    \ a custom ConstraintValidatorFactory\n| group | producer | javax.validation.groups.Default\
    \ | String | To use a custom validation group\n| messageInterpolator | producer\
    \ |  | MessageInterpolator | To use a custom MessageInterpolator\n| traversableResolver\
    \ | producer |  | TraversableResolver | To use a custom TraversableResolver\n\
    | validationProviderResolver | producer |  | ValidationProviderResolver | To use\
    \ a a custom ValidationProviderResolver\n| synchronous | advanced | false | boolean\
    \ | Sets whether synchronous processing should be strictly used or Camel is allowed\
    \ to use asynchronous processing (if supported).\n|=======================================================================\n\
    {% endraw %}\n// endpoint options: END\n\n\n[[BeanValidator-OSGideployment]]\n\
    OSGi deployment\n^^^^^^^^^^^^^^^\n\nTo use Hibernate Validator in the OSGi environment\
    \ use dedicated\n`ValidationProviderResolver` implementation, just as\n`org.apache.camel.component.bean.validator.HibernateValidationProviderResolver`.\n\
    The snippet below demonstrates this approach. Keep in mind that you can\nuse `HibernateValidationProviderResolver`\
    \ starting from the Camel\n2.13.0.\n\n*Using HibernateValidationProviderResolver*\n\
    \n[source,java]\n--------------------------------------------------------------------------------------------------------------------------------\n\
    from(\"direct:test\").\n  to(\"bean-validator://ValidationProviderResolverTest?validationProviderResolver=#myValidationProviderResolver\"\
    );\n\n...\n\n<bean id=\"myValidationProviderResolver\" class=\"org.apache.camel.component.bean.validator.HibernateValidationProviderResolver\"\
    /> \n--------------------------------------------------------------------------------------------------------------------------------\n\
    \nIf no custom\_`ValidationProviderResolver` is defined and the validator\ncomponent\
    \ has been deployed into the OSGi environment,\nthe\_`HibernateValidationProviderResolver`\
    \ will be automatically used.\n\n[[BeanValidator-Example]]\nExample\n^^^^^^^\n\
    \nAssumed we have a java bean with the following annotations\n\n*Car.java*\n\n\
    [source,java]\n-----------------------------------------------------------\npublic\
    \ class Car {\n\n    @NotNull\n    private String manufacturer;\n\n    @NotNull\n\
    \    @Size(min = 5, max = 14, groups = OptionalChecks.class)\n    private String\
    \ licensePlate;\n    \n    // getter and setter\n}\n-----------------------------------------------------------\n\
    \nand an interface definition for our custom validation group\n\n*OptionalChecks.java*\n\
    \n[source,java]\n---------------------------------\npublic interface OptionalChecks\
    \ {\n}\n---------------------------------\n\nwith the following Camel route, only\
    \ the *@NotNull* constraints on the\nattributes manufacturer and licensePlate\
    \ will be validated (Camel uses\nthe default group `javax.validation.groups.Default`).\n\
    \n[source,java]\n-------------------------\nfrom(\"direct:start\")\n.to(\"bean-validator://x\"\
    )\n.to(\"mock:end\")\n-------------------------\n\nIf you want to check the constraints\
    \ from the group `OptionalChecks`,\nyou have to define the route like this\n\n\
    [source,java]\n----------------------------------------------\nfrom(\"direct:start\"\
    )\n.to(\"bean-validator://x?group=OptionalChecks\")\n.to(\"mock:end\")\n----------------------------------------------\n\
    \nIf you want to check the constraints from both groups, you have to\ndefine a\
    \ new interface first\n\n*AllChecks.java*\n\n[source,java]\n-----------------------------------------------------\n\
    @GroupSequence({Default.class, OptionalChecks.class})\npublic interface AllChecks\
    \ {\n}\n-----------------------------------------------------\n\nand then your\
    \ route definition should looks like this\n\n[source,java]\n-----------------------------------------\n\
    from(\"direct:start\")\n.to(\"bean-validator://x?group=AllChecks\")\n.to(\"mock:end\"\
    )\n-----------------------------------------\n\nAnd if you have to provide your\
    \ own message interpolator, traversable\nresolver and constraint validator factory,\
    \ you have to write a route\nlike this\n\n[source,java]\n------------------------------------------------------------------------------------------------------\n\
    <bean id=\"myMessageInterpolator\" class=\"my.ConstraintValidatorFactory\" />\n\
    <bean id=\"myTraversableResolver\" class=\"my.TraversableResolver\" />\n<bean\
    \ id=\"myConstraintValidatorFactory\" class=\"my.ConstraintValidatorFactory\"\
    \ />\n\nfrom(\"direct:start\")\n.to(\"bean-validator://x?group=AllChecks&messageInterpolator=#myMessageInterpolator\n\
    &traversableResolver=#myTraversableResolver&constraintValidatorFactory=#myConstraintValidatorFactory\"\
    )\n.to(\"mock:end\")\n------------------------------------------------------------------------------------------------------\n\
    \nIt's also possible to describe your constraints as XML and not as Java\nannotations.\
    \ In this case, you have to provide the file\n`META-INF/validation.xml` which\
    \ could looks like this\n\n*validation.xml*\n\n[source,java]\n------------------------------------------------------------------------------------------------------------------------------\n\
    <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<validation-config\n    xmlns=\"http://jboss.org/xml/ns/javax/validation/configuration\"\
    \n    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n    xsi:schemaLocation=\"\
    http://jboss.org/xml/ns/javax/validation/configuration\">\n    <default-provider>org.hibernate.validator.HibernateValidator</default-provider>\n\
    \    <message-interpolator>org.hibernate.validator.engine.ResourceBundleMessageInterpolator</message-interpolator>\n\
    \    <traversable-resolver>org.hibernate.validator.engine.resolver.DefaultTraversableResolver</traversable-resolver>\n\
    \    <constraint-validator-factory>org.hibernate.validator.engine.ConstraintValidatorFactoryImpl</constraint-validator-factory>\n\
    \    \n    <constraint-mapping>/constraints-car.xml</constraint-mapping>\n</validation-config>\n\
    ------------------------------------------------------------------------------------------------------------------------------\n\
    \nand the `constraints-car.xml` file\n\n*constraints-car.xml*\n\n[source,java]\n\
    ----------------------------------------------------------------------------------------------------\n\
    <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<constraint-mappings xmlns:xsi=\"\
    http://www.w3.org/2001/XMLSchema-instance\"\n    xsi:schemaLocation=\"http://jboss.org/xml/ns/javax/validation/mapping\
    \ validation-mapping-1.0.xsd\"\n    xmlns=\"http://jboss.org/xml/ns/javax/validation/mapping\"\
    >\n    <default-package>org.apache.camel.component.bean.validator</default-package>\n\
    \    \n    <bean class=\"CarWithoutAnnotations\" ignore-annotations=\"true\">\n\
    \        <field name=\"manufacturer\">\n            <constraint annotation=\"\
    javax.validation.constraints.NotNull\" />\n        </field>\n        \n      \
    \  <field name=\"licensePlate\">\n            <constraint annotation=\"javax.validation.constraints.NotNull\"\
    \ />\n            \n            <constraint annotation=\"javax.validation.constraints.Size\"\
    >\n                <groups>\n                    <value>org.apache.camel.component.bean.validator.OptionalChecks</value>\n\
    \                </groups>\n                <element name=\"min\">5</element>\n\
    \                <element name=\"max\">14</element>\n            </constraint>\n\
    \        </field>\n    </bean>\n</constraint-mappings>\n----------------------------------------------------------------------------------------------------\n\
    \n[[BeanValidator-SeeAlso]]\nSee Also\n^^^^^^^^\n\n* link:configuring-camel.html[Configuring\
    \ Camel]\n* link:component.html[Component]\n* link:endpoint.html[Endpoint]\n*\
    \ link:getting-started.html[Getting Started]\n\n"
