mime-validator
v1.0.39
Published
Validate files by mime type
Downloads
43
Readme
mime-validator
Description
Validate file type against official MIME standard types
Build
npm run build
Tests
Test are using jest. To run tests use:
npm run test
Usage
Validate method accepts string or array as arguments. Returns boolean or throws exception if invalid argument.
import { validate, mimeType } from 'mime-validator';
type = 'application/xml';
validate(type, 'xml'); // => true
validate(type, ['application/xml', 'application/rss+xml', 'application/pdf']) // => false
validate(type, [mimeType.PNG, mimeType.GIF, mimeType.JPEG]) // => false
Contributing
We welcome and appreciate contributions from the community to help improve and enhance this project. Please follow these steps to contribute:
Fork the project to your GitLab account by clicking the "Fork" button at the top right of the project's GitLab page. This creates a copy of the project in your account.
Clone the forked repository to your local machine using Git. Replace
<your-username>
with your GitLab username.
git clone https://gitlab.com/<your-username>/mime-validator.git
- Create a new branch for your feature or bug fix. Use a clear and descriptive branch name that reflects the purpose of your changes.
git checkout -b feature-name
Make changes
Add and commit your changes with clear and descriptive commit messages.
git add .
git commit -m "Add feature XYZ" or "Fix issue #123"
- Push your branch to your GitLab fork:
git push origin feature-name
- Create a Pull Request
- Go to the GitLab page of your forked repository.
- Click on the "New Pull Request" button.
- Select the branch you just pushed (e.g., feature-name) as the source branch.
- Provide a clear title and description for your pull request. Reference any related issues, if applicable.
- Click the "Create Pull Request" button.
License
MIT © Branko Gabelica