Skip to content

Commit

Permalink
change to AMD, CMD
Browse files Browse the repository at this point in the history
  • Loading branch information
mycoin committed Jan 22, 2014
1 parent 91b2565 commit 1bae596
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 24 deletions.
2 changes: 1 addition & 1 deletion min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 11 additions & 22 deletions source.js
Expand Up @@ -25,27 +25,24 @@
* date: 2013/09/28
* repos: https://github.com/mycoin/validation
*/
;(function(ns, defination) {
if (typeof module != 'undefined') {
module.exports = defination();
} else if (typeof define == 'function' && typeof define.amd == 'object') {
define(defination);
} else {
this[ns] = defination();
}
})('validator', function() {
// use the trict mode
;(function (global, factory) {
//AMD and CMD.
typeof define === 'function' && define(factory);
//Node.js and Browser global
(typeof exports !== 'undefined' ? exports : global).validator = factory();
}(this, function () {
'use strict';

// exports object
var exports = {
version: 'stable-1.0'
version: 'stable-1.0.1'
};
/**
* notice String(undefined) == '', so assert null into ''
* @param Object {null, uindefined, String}, yes, toString method instead
* @return return a string that has been trimed.
*/
function trim(string) {
var trim = function (string) {
string == null && (string = undefined);
return String(string).replace(new RegExp('(^[\\s\\t\\xa0\\u3000]+)|([\\u3000\\xa0\\s\\t]+$)', 'g'), '');
};
Expand All @@ -58,7 +55,7 @@
* @param Object type
* @return Object value (optional)
*/
function restore(value, type) {
var restore = function (value, type) {
if (value === '' || value === undefined || value === null) {
value = type;
}
Expand Down Expand Up @@ -331,13 +328,5 @@
'message': 'OK'
};
};

exports.register = function (type, rules) {
if(! validators.hasOwnProperty('type') && typeof rules == 'function') {
validators[type] = rules;
return true;
}
return false;
};
return exports;
});
}));
2 changes: 1 addition & 1 deletion tests/index.html
Expand Up @@ -12,7 +12,7 @@ <h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup, will be hidden</div>
<script src="../lib.js"></script>
<script src="../source.js"></script>
<script src="qunit/qunit.js"></script>
<script src="tests.js"></script>
</body>
Expand Down

0 comments on commit 1bae596

Please sign in to comment.