Browse Source

#803: Add minSize option for the file validator, thanks to @Arkni

Phuoc Nguyen 11 years ago
parent
commit
fd26c0251c

+ 1 - 0
CHANGELOG.md

@@ -31,6 +31,7 @@ __Improvements__
 * [#754](https://github.com/nghuuphuoc/bootstrapvalidator/issues/754): Support latest Bootstrap when using tooltip/popover to show the message
 * [#783](https://github.com/nghuuphuoc/bootstrapvalidator/issues/783): Improve behaviour of the [different](http://bootstrapvalidator.com/validators/different/) validator
 * [#792](https://github.com/nghuuphuoc/bootstrapvalidator/pull/792): Add "BootstrapValidator's JavaScript requires jQuery" warning, thanks to [@Arkni](https://github.com/Arkni)
+* [#803](https://github.com/nghuuphuoc/bootstrapvalidator/pull/803): Add ```minSize``` option for the [file](http://bootstrapvalidator.com/validators/file/) validator, thanks to [@Arkni](https://github.com/Arkni)
 
 __Bug Fixes__
 * [#611](https://github.com/nghuuphuoc/bootstrapvalidator/issues/611), [#703](https://github.com/nghuuphuoc/bootstrapvalidator/issues/703): Tabs get red even form is valid

+ 1 - 1
dist/css/bootstrapValidator.min.css

@@ -2,7 +2,7 @@
  * BootstrapValidator (http://bootstrapvalidator.com)
  * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
  *
- * @version     v0.5.2-dev, built on 2014-09-09 8:35:08 AM
+ * @version     v0.5.2-dev, built on 2014-09-09 8:55:16 AM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT

+ 9 - 2
dist/js/bootstrapValidator.js

@@ -2,7 +2,7 @@
  * BootstrapValidator (http://bootstrapvalidator.com)
  * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
  *
- * @version     v0.5.2-dev, built on 2014-09-09 8:35:08 AM
+ * @version     v0.5.2-dev, built on 2014-09-09 8:55:16 AM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT
@@ -2783,6 +2783,7 @@ if (typeof jQuery === 'undefined') {
         html5Attributes: {
             extension: 'extension',
             maxsize: 'maxSize',
+            minsize: 'minSize',
             message: 'message',
             type: 'type'
         },
@@ -2795,6 +2796,7 @@ if (typeof jQuery === 'undefined') {
          * @param {Object} options Can consist of the following keys:
          * - extension: The allowed extensions, separated by a comma
          * - maxSize: The maximum size in bytes
+         * - minSize: the minimum size in bytes
          * - message: The invalid message
          * - type: The allowed MIME type, separated by a comma
          * @returns {Boolean}
@@ -2815,7 +2817,12 @@ if (typeof jQuery === 'undefined') {
                 var files = $field.get(0).files,
                     total = files.length;
                 for (var i = 0; i < total; i++) {
-                    // Check file size
+                    // Check the minSize
+                    if (options.minSize && files[i].size < parseInt(options.minSize, 10)) {
+                        return false;
+                    }
+                    
+                    // Check the maxSize
                     if (options.maxSize && files[i].size > parseInt(options.maxSize, 10)) {
                         return false;
                     }

File diff suppressed because it is too large
+ 4 - 4
dist/js/bootstrapValidator.min.js