Skip to content

Commit a7b30f3

Browse files
add validator into ConfigMapperFactory
1 parent 71eb637 commit a7b30f3

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ repositories {
1313
}
1414

1515
group = "org.embulk"
16-
version = "0.3.0-SNAPSHOT"
16+
version = "0.3.1"
1717
description = "Stores files on SFTP server."
1818

1919
sourceCompatibility = 1.8
@@ -50,6 +50,7 @@ dependencies {
5050
compile "com.fasterxml.jackson.core:jackson-databind:2.6.7"
5151
compile "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.6.7"
5252
compile "javax.validation:validation-api:1.1.0.Final"
53+
compile "org.apache.bval:bval-jsr303:0.5"
5354

5455
compile "org.embulk:embulk-util-retryhelper:0.8.2"
5556

gradle/dependency-locks/embulkPluginRuntime.lockfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ com.fasterxml.jackson.core:jackson-core:2.6.7
66
com.fasterxml.jackson.core:jackson-databind:2.6.7
77
com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.6.7
88
com.jcraft:jsch:0.1.55
9+
commons-beanutils:commons-beanutils-core:1.8.3
910
commons-io:commons-io:2.6
1011
commons-logging:commons-logging:1.2
1112
javax.validation:validation-api:1.1.0.Final
13+
org.apache.bval:bval-core:0.5
14+
org.apache.bval:bval-jsr303:0.5
15+
org.apache.commons:commons-lang3:3.1
1216
org.apache.commons:commons-vfs2:2.2
1317
org.embulk:embulk-util-config:0.3.1
1418
org.embulk:embulk-util-retryhelper:0.8.2

src/main/java/org/embulk/output/sftp/SftpFileOutputPlugin.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.embulk.output.sftp;
1818

19+
import org.apache.bval.jsr303.ApacheValidationProvider;
1920
import org.embulk.config.ConfigDiff;
2021
import org.embulk.config.ConfigSource;
2122
import org.embulk.config.TaskReport;
@@ -31,6 +32,8 @@
3132
import org.embulk.util.config.TaskMapper;
3233
import org.embulk.util.config.units.LocalFile;
3334

35+
import javax.validation.Validation;
36+
import javax.validation.Validator;
3437
import javax.validation.constraints.Max;
3538
import javax.validation.constraints.Min;
3639

@@ -180,7 +183,9 @@ public TransactionalFileOutput open(TaskSource taskSource, final int taskIndex)
180183
return new SftpRemoteFileOutput(task, taskIndex, Exec.getTempFileSpace());
181184
}
182185

183-
static final ConfigMapperFactory CONFIG_MAPPER_FACTORY = ConfigMapperFactory.builder().addDefaultModules().build();
186+
private static final Validator VALIDATOR =
187+
Validation.byProvider(ApacheValidationProvider.class).configure().buildValidatorFactory().getValidator();
188+
static final ConfigMapperFactory CONFIG_MAPPER_FACTORY = ConfigMapperFactory.builder().addDefaultModules().withValidator(VALIDATOR).build();
184189
static final ConfigMapper CONFIG_MAPPER = CONFIG_MAPPER_FACTORY.createConfigMapper();
185190
static final TaskMapper TASK_MAPPER = CONFIG_MAPPER_FACTORY.createTaskMapper();
186191
}

0 commit comments

Comments
 (0)