1.0.4 • Published 3 years ago
@creepycoder/containvalidator v1.0.4
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
Version | Date | Remark |
---|---|---|
1.0.0 | 04 September 2022 | Official first release |
1.0.1 | 04 September 2022 | Changes to README.md |
1.0.2 | 04 September 2022 | Changes to README.md |
1.0.3 | 04 September 2022 | Changes to package.json |
1.0.4 | 04 September 2022 | Changes 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