valid-filename

v4.0.0
Check if a string is a valid filename
regex regexp filename valid validate check detect is string and 1 more...

valid-filename

Check if a string is a valid filename

Install

$ npm install valid-filename

Usage

import isValidFilename from 'valid-filename';

isValidFilename('foo/bar');
//=> false

isValidFilename('foo-bar');
//=> true

API

isValidFilename(input)

Returns a boolean of whether input is a valid filename.

input

Type: string

The string to check.

Related

  • filenamify - Convert a string to a valid safe filename
npm i valid-filename

Metadata

  • MIT
  • ^12.20.0 || ^14.13.1 || >=16.0.0
  • Sindre Sorhus
  • released 8/16/2021

Downloads

Maintainers