]> gitweb.factorcode.org Git - factor.git/blob - basis/validators/validators-tests.factor
Create basis vocab root
[factor.git] / basis / validators / validators-tests.factor
1 IN: validators.tests
2 USING: kernel sequences tools.test validators accessors
3 namespaces assocs ;
4
5 [ "" v-one-line ] must-fail
6 [ "hello world" ] [ "hello world" v-one-line ] unit-test
7 [ "hello\nworld" v-one-line ] must-fail
8
9 [ "" v-one-word ] must-fail
10 [ "hello" ] [ "hello" v-one-word ] unit-test
11 [ "hello world" v-one-word ] must-fail
12
13 [ "foo" v-number ] must-fail
14 [ 123 ] [ "123" v-number ] unit-test
15 [ 123 ] [ "123" v-integer ] unit-test
16
17 [ "1.0" v-integer ] [ "must be an integer" = ] must-fail-with
18
19 [ "slava@factorcode.org" ] [
20     "slava@factorcode.org" v-email
21 ] unit-test
22
23 [ "slava+foo@factorcode.org" ] [
24     "slava+foo@factorcode.org" v-email
25 ] unit-test
26
27 [ "slava@factorcode.o" v-email ]
28 [ "invalid e-mail" = ] must-fail-with
29
30 [ "sla@@factorcode.o" v-email ]
31 [ "invalid e-mail" = ] must-fail-with
32
33 [ "slava@factorcodeorg" v-email ]
34 [ "invalid e-mail" = ] must-fail-with
35
36 [ "http://www.factorcode.org" ]
37 [ "http://www.factorcode.org" v-url ] unit-test
38
39 [ "http:/www.factorcode.org" v-url ]
40 [ "invalid URL" = ] must-fail-with
41
42 [ 4561261212345467 ] [ "4561261212345467" v-credit-card ] unit-test
43
44 [ 4561261212345467 ] [ "4561-2612-1234-5467" v-credit-card ] unit-test
45
46 [ 0 ] [ "0000000000000000" v-credit-card ] unit-test
47
48 [ "000000000" v-credit-card ] must-fail
49
50 [ "0000000000000000000000000" v-credit-card ] must-fail
51
52 [ "4561_2612_1234_5467" v-credit-card ] must-fail
53
54 [ "4561-2621-1234-5467" v-credit-card ] must-fail