Documentation v4.0.0

Overview

Check if the string is a valid file/directory path.

Import

import {validators} from 'metronic-extension';
const {isPath} = validators;

Signature

isPath(value: string): boolean
Returns: booleantrue if valid, false otherwise.

Example

Enter a file or directory path to validate in real time.
Result: true
<div class="mb-3">
  <label class="form-label">Input value</label>
  <input id="isPathInput" class="form-control form-control-solid" placeholder="Enter a file path..." value="/usr/local/bin">
</div>
<div>
  <span class="fw-bold">Result: </span>
  <span id="isPathResult" class="badge badge-success">true</span>
</div>
import {validators} from 'metronic-extension';
const {isPath} = validators;

isPath('/');          // true
isPath('/usr/lib');   // true
isPath('usr/lib/');   // true