file

Checks if the given string is a valid Windows file name.

Type signature

(name: string) => boolean

Examples

validName("my:file.png");
// ⇒ false
Try in REPL
validName("file.txt");
// ⇒ true
Try in REPL
validName("../file.txt");
// ⇒ false
Try in REPL
validName("COM1");
// ⇒ false
Try in REPL

Questions

  • How to find valid Windows file name?
  • How to check if a given string is a legal/valid file name under Windows?

TypeScript sourceJavaScript source