Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@patterninc/laravel_js_validator
Advanced tools
This package implements laravel styled validation rules in javascript. It is a standalone package and does not require any other package or framework to work. We can use this with ES6 and commonjs type of modules. Refer usage section for more details on the usage.
Add follwing to your package.json
"@patterninc/laravel_js_validator": "^1.0.1"
const laravel = require('@patterninc/laravel_js_validator')
laravel.Validator.validate(data, rules)
import { Validator } from '@patterninc/laravel_js_validator'
import { Validator } from '@patterninc/laravel_js_validator'
{
"data": {
"a1": "test",
"a2": null,
"a3": "",
"a4": [],
"a5": 10,
"a6": ["a", "b", "c"],
"a7": [1,2,3,4,5,6,7,8,9,10],
"a8": "*&^R$",
"a9": "test123",
"a10": "abc12312",
"a11": "abc@abc.com",
"a12": "abc",
"a13": "regex123"
},
"rules": {
"a1": "required",
"a2": "required",
"a3": "required",
"a4": "required",
"a5": "required|numeric|max:10|min:4",
"a6": "required|array|in:a,b,c",
"a7": "required|array|between:1,10",
"a8": "required|alpha",
"a9": "required|alpha_num",
"a10": "required|alpha",
"a11": "required|email",
"a12": "required|email",
"a13": "required|regex:/^regex[0-9]+$/"
}
}
const result = Validator.validate(data, rules)
console.log(result)
{
"success": false,
"errors": {
"a2": [
"The a2 field is required."
],
"a3": [
"The a3 field is required."
],
"a4": [
"The a4 field is required."
],
"a8": [
"The a8 may only contain letters."
],
"a10": [
"The a10 may only contain letters."
],
"a12": [
"The a12 must be a valid email address."
]
}
}
{
after: 'The :attr must be a date after :date.',
alpha: 'The :attr may only contain letters.',
alpha_dash: 'The :attr may only contain letters, numbers, and dashes.',
alpha_num: 'The :attr may only contain letters and numbers.',
array: 'The :attr must be an array.',
before: 'The :attr must be a date before :date.',
between: {
numeric: 'The :attr must be between :min and :max.',
string: 'The :attr must be between :min and :max characters.',
array: 'The :attr must have between :min and :max items.',
},
boolean: 'The :attr field must be true or false.',
date: 'The :attr is not a valid date.',
date_format: 'The :attr does not match the format :format.',
different: 'The :attr and :other must be different.',
email: 'The :attr must be a valid email address.',
in: 'The selected :attr is invalid.',
integer: 'The :attr must be an integer.',
max: {
numeric: 'The :attr may not be greater than :max.',
string: 'The :attr may not be greater than :max characters.',
array: 'The :attr may not have more than :max items.',
},
min: {
numeric: 'The :attr must be at least :min.',
string: 'The :attr must be at least :min characters.',
array: 'The :attr must have at least :min items.',
},
not_in: 'The selected :attr is invalid.',
numeric: 'The :attr must be a number.',
regex: 'The :attr format is invalid.',
required: 'The :attr field is required.',
same: 'The :attr and :other must match.',
size: {
numeric: 'The :attr must be :size.',
string: 'The :attr must be :size characters.',
array: 'The :attr must contain :size items.',
},
string: 'The :attr must be a string.',
url: 'The :attr format is invalid.',
}
FAQs
Validate values against Laravel validation rules
The npm package @patterninc/laravel_js_validator receives a total of 39 weekly downloads. As such, @patterninc/laravel_js_validator popularity was classified as not popular.
We found that @patterninc/laravel_js_validator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.