
Security News
Meet Socket at Black Hat Europe and BSides London 2025
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.
@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.19"
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": [
"Field is required."
],
"a3": [
"Field is required."
],
"a4": [
"Field is required."
],
"a8": [
"Value must only contain letters."
],
"a10": [
"Value must only contain letters."
],
"a12": [
"Value must be a valid email address."
]
}
}
{
after: 'Value must be a date after :date.',
alpha: 'Value must only contain letters.',
alpha_dash: 'Value must only contain letters, numbers, and dashes.',
alpha_num: 'Value must only contain letters and numbers.',
array: 'Value must be an array.',
before: 'Value must be a date before :date.',
between: {
numeric: 'Value must be between :min and :max.',
string: 'Value must be between :min and :max character(s).',
array: 'Value must have between :min and :max item(s).',
},
boolean: 'Value must be true or false.',
date: 'Value is not a valid date.',
date_format: 'Value does not match the format :format.',
different: 'The :attr and :other must be different.',
email: 'Value must be a valid email address.',
in: 'The selected value is invalid.',
integer: 'Value must be an integer.',
max: {
numeric: 'Value must not be greater than :max.',
string: 'Value must not be greater than :max character(s).',
array: 'Value must not have more than :max item(s).',
},
min: {
numeric: 'Value must be at least :min.',
string: 'Value must be at least :min character(s).',
array: 'Value must have at least :min item(s).',
},
not_in: 'The selected value is invalid.',
numeric: 'Value must be a number.',
regex: 'Value format is invalid.',
required: 'Field is required.',
same: 'The :attr and :other must match.',
size: {
numeric: 'Value must be :size.',
string: 'Value must be :size character(s).',
array: 'Value must contain :size item(s).',
},
string: 'Value must be a string.',
url: 'Value format is invalid.',
}
FAQs
Validate values against Laravel validation rules
The npm package @patterninc/laravel_js_validator receives a total of 375 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 10 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.

Security News
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.