1.0.4 • Published 3 years ago

@creepycoder/containvalidator v1.0.4

Weekly downloads
-
License
CC BY-NC-ND 4.0
Repository
-
Last release
3 years ago

Contain Validator

This library is small but easy to use. The purpose of this library is to check if a string contains a sub string. The library also do case sensitive checking.

Validation processes

The code contains two methods to check it a string contains as substring.

Compare method 1

This method is case sensative so both string and sub string must be the same case.

Compare method 2

This method is not case sensative so both string and sub string can contain any case.

Code sample

This following code is actually how I tested that all seven methods correctly functioned as intended, is also provided in this libery.

import subStringIsValid from './node_modules/@creepycoder/containvalidator/containvalidator.js';

console.log( "Testing Condition 1 Passed = " + subStringIsValid( "Hallo world" , "world" , true ) );
console.log( "Testing Condition 2 Passed = " + subStringIsValid( "Hallo world" , "World" , false ) );
console.log( "Testing Condition 3 Passed = " + !subStringIsValid( "Hallo world" , "beans" , true ) );
console.log( "Testing Condition 4 Passed = " + subStringIsValid( "Hallo world" , "world" ) );
console.log( "Testing Condition 5 Passed = " + !subStringIsValid( "Hallo world" , "World" ) );

The results will look as follows

Testing Condition 1 Passed = true
Testing Condition 2 Passed = true
Testing Condition 3 Passed = true
Testing Condition 4 Passed = true
Testing Condition 5 Passed = true

Function params

@param  {String}  source        The source string to be checked
@param  {String}  subString     The sub string the source must contain
@param  {Boolean} caseSensitive If validation must be case sensitive ( optional , default = true )
@return {Boolean}               The string passed/failed validation

Version History

VersionDateRemark
1.0.004 September 2022Official first release
1.0.104 September 2022Changes to README.md
1.0.204 September 2022Changes to README.md
1.0.304 September 2022Changes to package.json
1.0.404 September 2022Changes to README.md

How to install

Run the following command in a terminal or command prompt in the folder you want to install the module to.

npm i @creepycoder/containvalidator
1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago