npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

parsley-laravel-extras

v0.4.2

Published

Provides extra validation rules for ParsleyJS that translate well to rules that laravel has out-of-the-box

Downloads

56

Readme

ParsleyJS-LaraExtras

npm npm GitHub commits

These are extra parsley validation rules that translate well to laravel's own validation rules.

Be sure to take a look at the examples included in the repo.

Install

NPM

npm install parsley-laravel-extras

Next you can import or require it in your js:

require('parsley-laravel-extras')

import 'parsley-laravel-extras'

Or just include dist/laravel-parsley.js right after where you've included parsley.js.

Note Don't forget to include moment.js if you're using date validation.

Note If you'd like support for < IE9, include es5-shim.

Dates

Several date validation rules make use of a config option. This option let's you decide what formats are valid.

By default it looks for the following formats (in order):

window.Parsley.options.dateFormats = ['DD/MM/YY', 'DD/MM/YYYY', 'MM/DD/YY', 'MM/DD/YYYY', 'YY/MM/DD', 'YYYY/MM/DD'];

MomentJS does this strictly, meaning separators are also taken into account.

You can set your valid date formats the same way (this means that all parsley instances will get this assigned by default).

Or you can set it on your parsley instance:

$('form').parsley({
  dateFormats: ['DD-MM-YY', 'DD-MM-YYYY', 'MM-DD-YY', 'MM-DD-YYYY', 'YY-MM-DD', 'YYYY-MM-DD']
});

laravel-parsley.js

Here are all the included rules, written down as you'd assign them as data attributes to the input that would require them.

data-parsley-in="value,value,value,..."

The input's value should be in the provided comma separated list.

Laravel rule: in

data-parsley-not-in="value,value,value,..."

The input's value should not be in the provided comma separated list.

Laravel rule: not_in

data-parsley-different="#otherInput"

The input's value should not be the same as the specified other input element's value.

Laravel rule: between

data-parsley-between="[min,max]"

The input's value (a number) should be greater than min and smaller than max

data-parsley-size-number="size"

The input's value (a number) be the same as size.

Laravel rule: size

data-parsley-size-string="size"

The input's character count should be the same as size.

Laravel rule: size

data-parsley-date

The input's value should be a correct date string. Note that the separators don't matter.

Laravel rule: date

data-parsley-date-format="format"

The input's value should be the same format as specified. The format parameter only takes PHP date format characters link.

Laravel rule: date_format

data-parsley-before="before/date/here"

The input's value should be a date before the one specified as parameter.

Laravel rule: before

data-parsley-before-input="#other-input"

The input's value should be a date before the date from the #other-input's value

Laravel rule: before

data-parsley-after="after/date/here"

The input's value should be a date after the one specified as parameter.

Laravel rule: after

data-parsley-after-input="#other-input"

The input's value should be a date after the date from the #other-input's value

Laravel rule: after

data-parsley-disctinct

The input's values should be unique (checkboxes, radios, select multiple).

You can add the data-parsley-multiple="mymultiplelink" to the tags you want to include in the validation.

Laravel rule: distinct

data-parsley-in-array="#html-id|inputName"

The input's value should be present in one of the values of the provided element.

#html-id

When you specifiy an element starting with a hashtag we'll assume it's a text input that containts a comma separated list of values.

inputName

If you specify any other string we'll start looking for a checkbox with this string as name and snoop around its checked values.

Laravel rule: in_array

data-parsley-required-if="['#elementValueToCheck', 'value1,value2,..']"

The value is required only if another input's value matched one of its defined values.

Laravel rule: required_if

data-parsley-required-unless="['#elementValueToCheck', 'value1,value2,..']"

The value is required unless another input's value matched one of its defined values.

Laravel rule: required_unless

data-parsley-required-with="#elementToCheck,#elementToCheck,..."

The value is required if any of the inputs are present in the dom

Laravel rule: required_with

data-parsley-required-with-all="#elementToCheck,#elementToCheck,..."

The value is required if all of the specified inputs are present in the dom

Laravel rule: required_with_all

data-parsley-required-without="#elementToCheck,#elementCheck,..."

The value is required if any of the inputs are not present in the dom

Laravel rule: required_without

data-parsley-required-without-all="#elementToCheck,#elementToCheck,..."

The value is required if all of the specified inputs are not present in the dom

Laravel rule: required_without_all