@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 ADDED
@@ -0,0 +1,9 @@
1
+ # string-validator-lib
2
+
3
+ Lib simples para validação e tratamento de strings.
4
+
5
+ ## 📦 Instalação
6
+
7
+ ```bash
8
+ npm install @joaoidc/syge-validator
9
+ ```
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
+ };