
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
js-laravel-validation
Advanced tools
Set custom messages:
import { validate } from 'js-laravel-validation'
validate.setCustomMessage('required', ({ key, value }) => `${key} field is required.`)
The parameter to your createMessage
function will the same field object you supplied in your formData
. Differences are it will have a key
prop with the field name, and the validation
prop will be an array of rules (with parameters if any)
E.g:
validateForm({
name: {
value: "c mcg",
validation: 'required|string',
label: 'Full Name', //Custom property
}
})
will call the custom message function with
{
key: 'name',
validation: ['required', 'string'],
value: "c mcg",
label: 'Full Name',
}
Currently no dist is provided
import { validateForm } from 'js-laravel-validation'
const formData = {
username: {
value: 'test1',
validation: 'required|string'
},
password: {
value null,
validation: required|string'
}
}
const result = validateForm({
formData,
includeMessages: true,
});
if (result.errors) {
Object.keys(result.errors).forEach(key => {
const errors = result.errors[key];
errors.forEach(error => {
console.log(`invalid field field=${key} rule=${error.rule} messages=${error.message}`
}
}
}
FAQs
Laravel style form validation for JavaScript
The npm package js-laravel-validation receives a total of 43 weekly downloads. As such, js-laravel-validation popularity was classified as not popular.
We found that js-laravel-validation demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.