• R/O
  • SSH

micro-check: Commit

input validation library


Commit MetaInfo

Revisioncef614f5ad753e3de44139f66adcc6d36bf58476 (tree)
Time2018-04-23 17:43:25
Authorfrostbane <frostbane@prog...>
Commiterfrostbane

Log Message

Merge with feature/locale

Change Summary

Incremental Difference

diff -r e930dd4c09f9 -r cef614f5ad75 package.json
--- a/package.json Mon Apr 23 17:41:46 2018 +0900
+++ b/package.json Mon Apr 23 17:43:25 2018 +0900
@@ -1,20 +1,21 @@
11 {
2- "name" : "micro-check",
3- "version" : "v0.0.3",
4- "description" : "Object property validation",
5- "repository" : {
2+ "name" : "micro-check",
3+ "version" : "v0.0.3",
4+ "description" : "Object property validation",
5+ "repository" : {
66 "type": "hg",
77 "url" : "https://bitbucket.org/frostbane/micro-check"
88 },
9- "main" : "./microcheck.js",
10- "license" : "SEE LICENSE IN LICENSE.md",
11- "keywords" : [
9+ "main" : "./microcheck.js",
10+ "license" : "SEE LICENSE IN LICENSE.md",
11+ "keywords" : [
1212 "micro-check",
1313 "check-micro",
1414 "check",
1515 "validation"
1616 ],
1717 "devDependencies": {
18+ "requirejs" : "2.3.5",
1819 "jxunit" : "latest",
1920 "grunt-jxunit" : "latest",
2021 "jsdoc" : "latest",
@@ -25,9 +26,9 @@
2526 "grunt-contrib-copy" : "latest",
2627 "grunt-contrib-uglify": "latest"
2728 },
28- "dependencies": {
29+ "dependencies" : {
2930 },
30- "author" : {
31+ "author" : {
3132 "name" : "Frostbane Ac",
3233 "email": "frostbane@programmer.net"
3334 }
diff -r e930dd4c09f9 -r cef614f5ad75 src/microcheck.ja.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/microcheck.ja.js Mon Apr 23 17:43:25 2018 +0900
@@ -0,0 +1,127 @@
1+/*!
2+ .. ┌ -: .
3+ ([]▄▄├]▄▄▄¿┐`,
4+ .¡ ,. D{}▓███████████░█∩^} =
5+ ,▓¼ .▐▓▓█████████████▓██▓▓, (▓
6+ █▌╕. ─@╣████████████████████▄─ ./▀'
7+ :▓█▌Ç... └ '└▓██████████████████████Ö'` .. '└`'┌
8+ \ g█████▄Ü┌ C g██████████████████████████╗─ ² ² t▄▓██ù- `╞
9+ ¡ Å╠█▌╠█▓▓▓▓▌N@▌| ╓██████████████████████████▌ .╣▓▓▓▓▓▓▓]▐╙ÅÅ∩!
10+ ` ` ╫½┌▀▀▀▀▀▀░╫▌┘ ▀▀▀▀▀██████████████████▀█▀C :╝▀▀▀▀▀▀▀. `:
11+ L ─ⁿ'``' ─ ''' ─█████████████████▌─█= ╞º'`'º──
12+ ..Å╫█╛. ~
13+ ╔▄▄▓██▓▄¿ .
14+ - ]:├╣██▀▀▀▀▀▒Q¿.¿{ )=
15+ <─Ω╚█░▓███'──h⌂▓██╡██▌Ü─4
16+ `┌ ▐▓█▄▓██╟≤¡yQ▄███▓█▌▐▓M
17+ ^. └▀▀▄▓██▄▒▄▄╬▄████▀ └▀╙`
18+ «-'''█▓▓█▓██▓██▓▓██└``'⌐
19+ #╛ µ:▓▄;xφ(⌠ █
20+ ╗µ ~╙'` `┌█╣
21+ ╝Ñ. '' ' L▀▀
22+ ~ ,
23+ ^
24+ ÷ ─.
25+ N. ∩ts )
26+ ∩ ²⌠ ` ─
27+ (@ ~▒▒ .
28+ ` └▀/ .>▀▀ :
29+ ⌐ ,⌐
30+
31+
32+ Object property validation
33+ Version 0.0.3
34+ Copyright (c) 2016, 2017 Frostbane Ac
35+ See LICENSE.md.
36+ www.??.com
37+
38+
39+ */
40+
41+/*
42+ * 2016.08.12
43+ * frostbane
44+ *
45+ *
46+ *
47+ */
48+
49+// todo fix globals
50+/* global
51+MicroCheck,
52+isInt,
53+isFloat,
54+format,
55+getDecimalCount,
56+trim,
57+define
58+ */
59+
60+/* jshint
61+bitwise: false,
62+maxlen: 180
63+ */
64+
65+(function(global, factory){
66+ "use strict";
67+
68+ if(typeof define === typeof function(){} && define.amd !== undefined){
69+ define(function(){
70+ return factory;
71+ });
72+ }else if(typeof exports !== typeof undefined && global.exports !== exports){
73+ module.exports = factory;
74+ }else{
75+ global.MicroCheck.message = factory;
76+ }
77+
78+}(this, (function(){
79+ "use strict";
80+
81+ var message = {
82+ required :function(){
83+ return '"' + this.name + '" は必須項目です。';
84+ },
85+ regex_match :function(){
86+ return '"' + this.name + '" は正規表現 "' + this.rule.value + '" が。。。';
87+ },
88+ matches :function(){
89+ return '"' + this.name + '" は "' + this.rule.value + '" と一致していません。';
90+
91+ },
92+ matches_exact :function(){
93+ return '"' + this.name + '" は "' + this.rule.value + '" と一致していません。';
94+
95+ },
96+ min_length :function(){
97+ return '"' + this.name + '" の最低桁数は "' + this.rule.value + '" けたです。';
98+ },
99+ max_length :function(){
100+ return '"' + this.name + '" の最大桁数は "' + this.rule.value + '" 桁です。';
101+ },
102+ exact_length :function(){
103+ return '"' + this.name + '" は "' + this.rule.value + '" 桁が必要です。';
104+ },
105+ valid_email :function(){
106+ return '"' + this.value + '" は無効なメールアドレスです。';
107+ },
108+ alpha :function(){
109+ return '"' + this.value + '" にはロマジ以外が入っています。';
110+ },
111+ alpha_numeric :function(){
112+ return '"' + this.value + '" には英数字以外が入っています。';
113+ },
114+ numeric :function(b){
115+ return b ?
116+ '"' + this.value + '" は数字ではありません。' :
117+ '"' + this.value + '" は数字です。';
118+ },
119+ single_byte :function(){
120+ return '"' + this.value + '" UNICODE 文字が入っています。';
121+ },
122+
123+ };
124+
125+ return message;
126+
127+}())));
diff -r e930dd4c09f9 -r cef614f5ad75 test/microcheck.test.amd.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/microcheck.test.amd.html Mon Apr 23 17:43:25 2018 +0900
@@ -0,0 +1,19 @@
1+<!DOCTYPE html>
2+
3+<html>
4+<head>
5+ <meta charset="utf-8" />
6+
7+</head>
8+<body>
9+ <h3>micro-check test runner</h3>
10+ <p>open console to see the results</p>
11+
12+ <div>
13+ <script type="text/javascript" src="../node_modules/requirejs/require.js" data-main="require.amd.main.js"></script>
14+
15+
16+ </div>
17+
18+</body>
19+</html>
diff -r e930dd4c09f9 -r cef614f5ad75 test/microcheck.test.html
--- a/test/microcheck.test.html Mon Apr 23 17:41:46 2018 +0900
+++ b/test/microcheck.test.html Mon Apr 23 17:43:25 2018 +0900
@@ -9,6 +9,8 @@
99 <script type="text/javascript"
1010 src="../src/microcheck.js"></script>
1111 <script type="text/javascript"
12+ src="../src/microcheck.ja.js"></script>
13+ <script type="text/javascript"
1214 src="microcheck.test.js"></script>
1315 <script type="text/javascript">
1416 var Test = JxUnit.extend(checkmicrotest);
@@ -17,7 +19,7 @@
1719 clearOnStart :true,
1820 stopOnFail :false,
1921 stopOnException :true,
20- verbose :false,
22+ verbose :true,
2123 autoStart :false,
2224 outputColor :true,
2325 debugMode :false,
diff -r e930dd4c09f9 -r cef614f5ad75 test/require.amd.main.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/require.amd.main.js Mon Apr 23 17:43:25 2018 +0900
@@ -0,0 +1,93 @@
1+/* jshint
2+forin: false,
3+nonew: false,
4+proto: true
5+ */
6+
7+/* global
8+require,
9+define,
10+Promise,
11+$
12+ */
13+require.config({
14+ paths :{
15+ "microCheckJa" :"../src/microcheck.ja",
16+ "microCheck" :"../src/microcheck",
17+ },
18+
19+ waitSeconds :200,
20+
21+ shim :{
22+ "microCheckJa" :{
23+ deps :["microCheck"],
24+ },
25+ },
26+
27+ deps :[""],
28+});
29+
30+define(
31+ "uC",
32+ [
33+ "microCheck",
34+ "microCheckJa",
35+ ],
36+ function(uc, lang){
37+ "use strict";
38+
39+ uc.message = lang;
40+
41+ return uc;
42+
43+ });
44+
45+require(["uC"], function(uC){
46+ "use strict";
47+
48+ var test = function(){
49+
50+ var doubleByteData = {
51+ double3 :"0123456789",
52+ doubleC :"ABCDEFGHIJ",
53+ halfKana :"カタカナ",
54+ };
55+
56+ var validationRules = [
57+ [
58+ "double byte number",
59+ "double3",
60+ {
61+ single_byte :true,
62+ },
63+ ],
64+ [
65+ "double byte letter",
66+ "doubleC",
67+ {
68+ single_byte :true,
69+ },
70+ ],
71+ [
72+ "half width kana",
73+ "halfKana",
74+ {
75+ single_byte :true,
76+ },
77+ ],
78+ ];
79+
80+ var cm = new uC(validationRules)
81+ .setData(doubleByteData);
82+
83+ var result = cm.validate();
84+ debugger;
85+
86+ };
87+
88+ test();
89+
90+});
91+
92+
93+
Show on old repository browser