Various fixes

db4
Slava Pestov 2008-05-27 01:18:38 -05:00
parent 5f4ffa998f
commit 8278ac5b28
7 changed files with 41 additions and 10 deletions

View File

@ -10,7 +10,7 @@
<tr>
<th class="field-label">User name:</th>
<td><t:field t:name="username" /></td>
<td><t:label t:name="username" /></td>
</tr>
<tr>

View File

@ -63,7 +63,7 @@
<p>
<input type="submit" value="Register" />
<t:validation-message />
<t:validation-messages />
</p>

View File

@ -47,6 +47,21 @@ namespaces assocs ;
[ "http:/www.factorcode.org" v-url ]
[ "invalid URL" = ] must-fail-with
[ 4561261212345467 ] [ "4561261212345467" v-credit-card ] unit-test
[ 4561261212345467 ] [ "4561-2612-1234-5467" v-credit-card ] unit-test
[ 0 ] [ "0000000000000000" v-credit-card ] unit-test
[ "000000000" v-credit-card ] must-fail
[ "0000000000000000000000000" v-credit-card ] must-fail
[ "4561_2612_1234_5467" v-credit-card ] must-fail
[ "4561-2621-1234-5467" v-credit-card ] must-fail
[ 14 V{ } ] [
[
"14" "age" [ v-number 13 v-min-value 100 v-max-value ] validate

View File

@ -1,9 +1,9 @@
! Copyright (C) 2006, 2008 Slava Pestov
! See http://factorcode.org/license.txt for BSD license.
USING: kernel continuations sequences math namespaces sets
math.parser assocs regexp fry unicode.categories sequences
arrays hashtables words combinators mirrors classes quotations
xmode.catalog ;
USING: kernel continuations sequences sequences.lib math
namespaces sets math.parser math.ranges assocs regexp fry
unicode.categories arrays hashtables words combinators mirrors
classes quotations xmode.catalog ;
IN: validators
: v-default ( str def -- str )
@ -91,6 +91,23 @@ IN: validators
"not a valid syntax mode" throw
] unless ;
: luhn? ( n -- ? )
string>digits <reversed>
[ odd? [ 2 * 10 /mod + ] when ] map-index
sum 10 mod 0 = ;
: v-credit-card ( str -- n )
"- " diff
dup CHAR: 0 CHAR: 9 [a,b] diff empty? [
13 v-min-length
16 v-max-length
dup luhn? [ string>number ] [
"card number check failed" throw
] if
] [
"invalid credit card number format" throw
] if ;
SYMBOL: validation-messages
SYMBOL: named-validation-messages

View File

@ -12,7 +12,6 @@ http.server.auth.login
http.server.auth
http.server.sessions
http.server.actions
http.server.crud
http.server ;
IN: webapps.user-admin

View File

@ -166,10 +166,10 @@ TUPLE: wiki < dispatcher ;
<main-article-action> "" add-responder
<view-article-action> "view" add-responder
<view-revision-action> "revision" add-responder
<edit-article-action> { } <protected> "edit" add-responder
<list-revisions-action> "revisions" add-responder
<delete-action> "delete" add-responder
<diff-action> "diff" add-responder
<list-articles-action> "articles" add-responder
<edit-article-action> { } <protected> "edit" add-responder
<delete-action> { } <protected> "delete" add-responder
<boilerplate>
"wiki-common" wiki-template >>template ;

View File

@ -1,4 +1,4 @@
USING: xmode.tokens xmode.marker xmode.catalog kernel html
USING: xmode.tokens xmode.marker xmode.catalog kernel
html.elements io io.files sequences words io.encodings.utf8
namespaces xml.entities ;
IN: xmode.code2html