Search in sources :

Example 1 with Verify

use of io.github.ihongs.util.verify.Verify 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()));
    }
}
Also used : IsNumber(io.github.ihongs.util.verify.IsNumber) Required(io.github.ihongs.util.verify.Required) Wrongs(io.github.ihongs.util.verify.Wrongs) IsString(io.github.ihongs.util.verify.IsString) Repeated(io.github.ihongs.util.verify.Repeated) Verify(io.github.ihongs.util.verify.Verify) Map(java.util.Map) Test(org.junit.Test)

Aggregations

IsNumber (io.github.ihongs.util.verify.IsNumber)1 IsString (io.github.ihongs.util.verify.IsString)1 Repeated (io.github.ihongs.util.verify.Repeated)1 Required (io.github.ihongs.util.verify.Required)1 Verify (io.github.ihongs.util.verify.Verify)1 Wrongs (io.github.ihongs.util.verify.Wrongs)1 Map (java.util.Map)1 Test (org.junit.Test)1