use of io.github.ihongs.util.verify.IsString in project HongsCORE by ihongs.
the class TestVerify method testVerify.
@Test
public void testVerify() throws IOException {
// 避免路径缺失致写入项目主目录
CmdletRunner.init(new String[] { "--COREPATH", "target" });
try {
Verify verify = new Verify().addRule("name", new Required(), new IsString().config(Synt.mapOf("minlength", 3, "maxlength", 8))).addRule("size", new Repeated().config(Synt.mapOf("slice", ",")), new IsNumber().config(Synt.mapOf("min", 10, "max", 99)));
Map values = Synt.mapOf("name", "abcdef", "size", "11,22");
Map cleans = verify.verify(values, false, false);
Map cleanz = Synt.mapOf("name", "abcdef", "size", Arrays.asList(11, 22));
// System.out.println(Dawn.toString(cleans));
// System.out.println(Dawn.toString(cleanz));
assertEquals(Dawn.toString(cleans, true), Dawn.toString(cleanz, true));
} catch (Wrongs wr) {
Core.ACTION_LANG.set(Cnst.LANG_DEF);
fail(Dawn.toString(wr.getErrors()));
}
}
Aggregations