npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@creativeacer/spnamevalidator

v8.1.1

Published

SharePoint - Custom Input Validator

Readme

SPNameValidator CodeFactor

This validator will help you validate names for SharePoint 2013/2016 or SharePoint Online.
The validation can be used for Lib/list names, file names and Site-Subsite names.

The purpose of this library is to check field inputs by users.
For example if a form is used to create a new list / listItem / ... this code will check if the input is valid for the selected sharepoint version.

DEFAULT - The validator uses the characters and words defined by microsoft as being illegal for both File - Folder - Library - List - Site
Donate

CUSTOM - Next to those you also have the option to set custom characters and words.

BOTH - You also have the option to validate the input on both custom and default characters and words.

I will refer to DEFAULT - CUSTOM - BOTH in the instructions

Donations

If you would like to donate anything, you can always use the following link. Much appreciated! ;)

Donate

Installation

    npm i @creativeacer/spnamevalidator

Usage

include the libary
TS

    import SPNameValidator, { Platform, ValidationType } from '@creativeacer/spnamevalidator/SPNameValidator';

JS

    var SPNameValidator = require('@creativeacer/spnamevalidator/SPNameValidator').default;
    var Platform = require('@creativeacer/spnamevalidator/SPNameValidator').Platform;
    var ValidationType = require('@creativeacer/spnamevalidator/SPNameValidator').ValidationType;

Standard SharePoint illegal char and word list

choose your SharePoint version

    let spNameValidator = new SPNameValidator(Platform["SharePoint 2013 - 2016"]);
    or
    let spNameValidator = new SPNameValidator(Platform["SharePoint Online"]);

Using checkName function!

DEFAULT - perform a check on a name / entry

    this.spNameValidator.checkName(string, ValidationType["File - Folder"]);
    or
    this.spNameValidator.checkName(string, ValidationType["ListName"]);
    or
    this.spNameValidator.checkName(string, ValidationType["Site"]);

This check will use the Default microsoft characters and words When the string is valid true will be returned.

Custom illegal char and word list

If you would like to use a custom character or wordset you can do this by setting the desired illegal characters or words:


    let customSPNameValidator = new SPNameValidator(Platform["SharePoint 2013 - 2016"]);
    or
    let customSPNameValidator = new SPNameValidator(Platform["SharePoint Online"]);

    // Set the characters and words
    this.customSPNameValidator.setIllegalCharset(['a', '#', '7']);
    this.customSPNameValidator.setIllegalWordset(['One', 'Work', 'Just']);

Characters are Case sensitive!
during validation: w !== W
words will be transformerd to uppercase
during validation: Word === WORD

Using checkCustomValue function!

CUSTOM without the default microsoft defined char and words

    this.spNameValidator.checkCustomValue(string, ValidationType["File - Folder"]);
    or
    this.spNameValidator.checkCustomValue(string, ValidationType["ListName"]);
    or
    this.spNameValidator.checkCustomValue(string, ValidationType["Site"]);

BOTH or with the default microsoft defined char and words - add true as third parameter

    this.spNameValidator.checkCustomValue(string, ValidationType["File - Folder"], true);
    or
    this.spNameValidator.checkCustomValue(string, ValidationType["ListName"], true);
    or
    this.spNameValidator.checkCustomValue(string, ValidationType["Site"], true);

When the string is valid true will be returned.

Example test for Runkit

    var SPNameValidator = require('@creativeacer/spnamevalidator/SPNameValidator').default;
    var Platform = require('@creativeacer/spnamevalidator/SPNameValidator').Platform;
    var ValidationType = require('@creativeacer/spnamevalidator/SPNameValidator').ValidationType;

    var validator = new SPNameValidator(Platform['SharePoint 2013 - 2016']);
    // should return false
    var result = validator.checkName('_test', ValidationType['File - Folder']);
    console.log('_test ' + result);
    // should return true
    var result = validator.checkName('test', ValidationType['File - Folder']);
    console.log('test ' + result);

Happy coding!