js-textfield-validation
Advanced tools
Comparing version 1.0.6 to 1.0.7
declare class Validation { | ||
constructor(value: string); | ||
// Chainable methods | ||
alphanumericOnly(): void; | ||
@@ -13,2 +14,4 @@ dollarValue(): void; | ||
wordOnly(): void; | ||
// Non-chainable methods | ||
validateEmail(email: string): void; | ||
@@ -15,0 +18,0 @@ validateIPAddress(address: string): void; |
16
index.js
@@ -6,2 +6,3 @@ export default class Validation { | ||
}; | ||
/** Remove all the spaces */ | ||
@@ -62,3 +63,3 @@ Validation.prototype.noSpace = function() { | ||
Validation.prototype.ipAddress = function() { | ||
this.value = this.value.replace(/([^0-9.])|(^[.])/, "").replace(/[.]{2}/, "."); | ||
this.value = this.value.replace(/([^0-9.])|(^[.]+)/, ""); | ||
return this; | ||
@@ -110,4 +111,15 @@ } | ||
export const validateIPAddress = address => { | ||
let isValid = true; | ||
const regExpTest = RegExp("^\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}$"); | ||
return (regExpTest.test(address)) | ||
isValid = regExpTest.test(address); | ||
if (isValid) { | ||
const values = address.split('.') | ||
for (let i=0; i<4; i++) { | ||
if (values[i] > 255) { | ||
isValid = false; | ||
break; | ||
} | ||
} | ||
} | ||
return isValid; | ||
} |
{ | ||
"name": "js-textfield-validation", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "An npm Package to validate textfield value.", | ||
@@ -8,3 +8,3 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "jasmine" | ||
}, | ||
@@ -32,3 +32,6 @@ "repository": { | ||
"author": "Lerh Hwee Lern", | ||
"license": "MIT" | ||
"license": "MIT", | ||
"devDependencies": { | ||
"jasmine": "^3.4.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
16222
10
303
1
1
1