Skip to content

Commit

Permalink
Merge pull request #49 from Anushkabh/anubh
Browse files Browse the repository at this point in the history
String Sanitization Implementation Part -1
  • Loading branch information
Jagroop2001 authored Feb 18, 2024
2 parents e1af865 + 5e376ea commit fe85fac
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,15 @@ This function remove the space from the string .
validator.removeUnderscore(str)
This function remove the underscore from the string .
```
```
validator.removeNumber(str)
This function remove the number from string.
```
```
validator.addFullstop(str)
This function replaces space in string with fullstop.
```


# Contributing Guidelines

Expand Down
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ import {
addUnderscore,
removeSpace,
removeUnderscore,
addFullstop,
removeNumber,

} from "./utils/utilityFunctions";


Expand Down Expand Up @@ -87,6 +90,8 @@ const validator = {
removeUnderscore,
generateJWT,
decodeJWT,
addFullstop,
removeNumber,
};

export default validator;
13 changes: 13 additions & 0 deletions src/utils/utilityFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,16 @@ export function removeSpace(inputString: string): string {
export function removeUnderscore(inputString: string): string {
return inputString.replace(/_/g, '');
}

// Remove numbers from a string
export const removeNumber = (str: string): string => {
return str.replace(/[0-9]/g, '');
};

// Replace spaces with full stop
export const addFullstop = (str: string): string => {
return str.replace(/\s/g, '.');
};



0 comments on commit fe85fac

Please sign in to comment.