examples/validation/dist/index.js
function image(input) {
        return new Promise(function (valid, invalid) {
            if (input.getAttribute('type') === 'file' && input.getAttribute('accept').indexOf('image') > -1 && _bn_getFile(input) !== false) {
                BunnyFile.getSignature(_bn_getFile(input)).then(function (signature) {
                    if (BunnyFile.isJpeg(signature) || BunnyFile.isPng(signature)) {
                        valid();
                    } else {
                        invalid({ signature: signature });
                    }
                }).catch(function (e) {
                    invalid(e);
                });
            } else {
                valid();
            }
        });
    }
function image(input) {
        return new Promise(function (valid, invalid) {
            if (input.getAttribute('type') === 'file' && input.getAttribute('accept').indexOf('image') > -1 && _bn_getFile(input) !== false) {
                BunnyFile.getSignature(_bn_getFile(input)).then(function (signature) {
                    if (BunnyFile.isJpeg(signature) || BunnyFile.isPng(signature)) {
                        valid();
                    } else {
                        invalid({ signature: signature });
                    }
                }).catch(function (e) {
                    invalid(e);
                });
            } else {
                valid();
            }
        });
    }
function image ( input ) { return new Promise ( function ( valid , invalid ) { if ( input . getAttribute ( 'type' ) === 'file' && input . getAttribute ( 'accept' ) . indexOf ( 'image' ) > - 1 && _bn_getFile ( input ) !== false ) { BunnyFile . getSignature ( _bn_getFile ( input ) ) . then ( function ( signature ) { if ( BunnyFile . isJpeg ( signature ) || BunnyFile . isPng ( signature ) ) { valid ( ) ; } else { invalid ( { signature : signature } ) ; } } ) . catch ( function ( e ) { invalid ( e ) ; } ) ; } else { valid ( ) ; } } ) ; }
if file input has "accept" attribute and it contains "image", then check if uploaded file is a JPG or PNG
if file input has accept attribute and it contains image then check if uploaded file is a JPG or PNG