Skip to content

Latest commit

 

History

History
65 lines (48 loc) · 1.19 KB

README.md

File metadata and controls

65 lines (48 loc) · 1.19 KB

PDF Front-end Validator


Overview   |    Install   

Overview

The PDF Front Validator library is a tool that simplifies the process of validating PDF files when developing front-end interfaces.

Use the main function to validate whether a file is in fact a PDF or whether it has been renamed with the pdf extension.

Technology

  • ⚛️ React 18
  • ⛑ TypeScript
  • ⛑ Vite
  • 📏 ESLint
  • 💖 Prettier

Install

NPM:

npm i pdf-front-validator

Yarn

yarn add pdf-front-validator

Usage

React example

import { validateFilePDF } from 'pdf-front-validator'

function App() {
  const selectedFile = e.target.files[0]

    validateFilePDF(selectedFile)
    .then((result) => {
      if (result !== undefined) {
        // It's a PDF file
      } else {
        // It's not a PDF file
      }
    })
    .catch((error) => {
      console.error("Error to validate PDF File. ln: 58 Error => ", error);
      return;
    });
}

Made with 💗 by Patrick Gratão