@joaoidc/syge-validator 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/package.json +14 -0
- package/string-validator-lib/lib/index.js +18 -0
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@joaoidc/syge-validator",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Lib simples para validação e tratamento de strings",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"string",
|
|
8
|
+
"validator",
|
|
9
|
+
"split",
|
|
10
|
+
"utils"
|
|
11
|
+
],
|
|
12
|
+
"author": "joaoidc",
|
|
13
|
+
"license": "MIT"
|
|
14
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Divide uma string em array com base em um separador
|
|
3
|
+
* @param {string} value
|
|
4
|
+
* @param {string} separator
|
|
5
|
+
* @returns {string[]}
|
|
6
|
+
*/
|
|
7
|
+
function splitString(value, separator = "|") {
|
|
8
|
+
if (typeof value !== "string") return [];
|
|
9
|
+
|
|
10
|
+
return value
|
|
11
|
+
.split(separator)
|
|
12
|
+
.map((item) => item.trim())
|
|
13
|
+
.filter(Boolean);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
module.exports = {
|
|
17
|
+
splitString,
|
|
18
|
+
};
|