Skip to content

Commit

Permalink
- added type=phone validator. Allow isValid on both form and fields. Fix
Browse files Browse the repository at this point in the history
 guillaumepotier#177. Tagged 1.1.15
  • Loading branch information
guillaumepotier committed Mar 21, 2013
1 parent fa1d1cf commit 4157ec3
Show file tree
Hide file tree
Showing 10 changed files with 238 additions and 191 deletions.
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
#Changelog

**1.1.15 (next version)**
**1.1.15 (current stable)**

- this.constraints is now an object instead of an array. BC break with onFieldError
- **BC Break** removed `.parsley('isFieldValid');` in favor of `.parsley('isValid');`
(#177)
- added type="phone" validator
- this.constraints is now an object instead of an array. **BC Break** with onFieldError
listener.
- removed default 'i' flag with data-regex validator. Added data-regex-flag attribute
(#168)
- specific behavior when field have required constraint. Do not show required error
along another errors, and reciprocally (#142)

**1.1.14 (current stable)**
**1.1.14**

- added luhn validator in parsley.extra (#150)
- added inlist validator in parsley.extra (#153)
Expand Down
67 changes: 34 additions & 33 deletions dist/parsley-standalone.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/parsley.extend.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 34 additions & 33 deletions dist/parsley.min.js

Large diffs are not rendered by default.

171 changes: 100 additions & 71 deletions documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ <h2>Documentation</h2>
<ol>
<li><a href="#basic-constraints">Basic constraints</a></li>
<li><a href="#type-constraints">Type constraints</a></li>
<li><a href="#extra-constraints">Extra constraints</a></li>
</ol>
</li>
<li>
Expand Down Expand Up @@ -989,8 +990,106 @@ <h4>Type Constraints</h4>
</td>
</tr>

<!-- Phone -->
<tr>
<td>Phone</td>
<td>
<code>data-type="phone"</code>
</td>
<td>Validates that a value is a valid phone number.</td>
<td class="not-for-mobile">
<table>
<tr>
<td>
<form data-validate="parsley">
<input type="text" id="data-phone" data-type="phone" placeholder="(XXX) XXXX XXX" />
</form>
</td>
<td>
<span class="btn btn-small" onclick="javascript:$('#data-phone').parsley('validate');">
<i class="icon-ok"></i>
</span>
</td>
</tr>
</table>
</td>
</tr>

</tbody>
</table>

<a name="extra-constraints"></a>
<h4>Extra Validators</h4>
<p>
There are some extra validators, not shipped along with default Parsley, because they're more specific and less common, and there is no need to add weight to Parsley instead of calling these validators only when needed. Just call <code>parsley.extend.js</code> or <code>dist/parsley.extend.min.js</code> like this:
<pre><code>&lt;script type="text/javascript" src="parsley.extend.fr.js">&lt;/script>
&lt;script type="text/javascript" src="parsley.js">&lt;/script></code></pre>
Please, feel free to <a href="http://github.com/guillaumepotier/Parsley.js">fork and contribute</a> by adding some useful validators!
</p>
<br/>

<h5>Here is the list of parsley.extra validators</h5>
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>Name</th>
<th>Api</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>Min Words</td>
<td><code>data-minwords="6"</code></td>
<td>Validate that a field has at least 6 words.</td>
</tr>
<tr>
<td>Max Words</td>
<td><code>data-maxwords="6"</code></td>
<td>Validate that a field has 6 words maximum.</td>
</tr>
<tr>
<td>Range Words</td>
<td><code>data-rangewords="[6,10]"</code></td>
<td>Validate that a field has between 6 and 10 words.</td>
</tr>
<tr>
<td>Greater Than</td>
<td><code>data-greaterthan="#elem"</code></td>
<td>Validate that a field's value is greater than #elem's value.</td>
</tr>
<tr>
<td>Less Than</td>
<td><code>data-lessthan="#elem"</code></td>
<td>Validate that a field's value is lower than #elem's value.</td>
</tr>
<tr>
<td>Before date</td>
<td><code>data-beforedate="#elem"</code></td>
<td>Validate that a field's date is before #elem's date.</td>
</tr>
<tr>
<td>After date</td>
<td><code>data-afterdate="#elem"</code></td>
<td>Validate that a field's date is after #elem's date.</td>
</tr>
<tr>
<td>In list</td>
<td><code>data-inlist="foo, bar, foo bar"</code></td>
<td>
Validates that a field's value is present within the value list. You can define the delimiter using <code>data-inlist-delimiter=","</code>. Delimiter defaults to <code>","</code>.
</td>
</tr>
<tr>
<td>Luhn</td>
<td><code>data-luhn="true"</code></td>
<td>
Validates that a fields value passes the Luhn algorithm. Validates credit card numbers, as well as some other kinds of account numbers.
</td>
</tr>
</tbody>
</table>

</section>
<a href="#top" class="top pull-right">Top</a>

Expand Down Expand Up @@ -1279,77 +1378,7 @@ <h4>Localizations</h4>
&lt;script type="text/javascript" src="parsley.js">&lt;/script></code></pre>
Please, feel free to <a href="http://github.com/guillaumepotier/Parsley.js">fork and contribute</a> by adding your own translations messages in your language!
</p>
<br/><br/>
<h4>Extra Validators</h4>
<p>
There are some extra validators, not shipped along with default Parsley, because they're more specific and less common, and there is no need to add weight to Parsley instead of calling these validators only when needed. Just call <code>parsley.extend.js</code> or <code>dist/parsley.extend.min.js</code> like this:
<pre><code>&lt;script type="text/javascript" src="parsley.extend.fr.js">&lt;/script>
&lt;script type="text/javascript" src="parsley.js">&lt;/script></code></pre>
Please, feel free to <a href="http://github.com/guillaumepotier/Parsley.js">fork and contribute</a> by adding some useful validators!
</p>
<br/>

<h5>Here is the list of parsley.extra validators</h5>
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>Name</th>
<th>Api</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>Min Words</td>
<td><code>data-minwords="6"</code></td>
<td>Validate that a field has at least 6 words.</td>
</tr>
<tr>
<td>Max Words</td>
<td><code>data-maxwords="6"</code></td>
<td>Validate that a field has 6 words maximum.</td>
</tr>
<tr>
<td>Range Words</td>
<td><code>data-rangewords="[6,10]"</code></td>
<td>Validate that a field has between 6 and 10 words.</td>
</tr>
<tr>
<td>Greater Than</td>
<td><code>data-greaterthan="#elem"</code></td>
<td>Validate that a field's value is greater than #elem's value.</td>
</tr>
<tr>
<td>Less Than</td>
<td><code>data-lessthan="#elem"</code></td>
<td>Validate that a field's value is lower than #elem's value.</td>
</tr>
<tr>
<td>Before date</td>
<td><code>data-beforedate="#elem"</code></td>
<td>Validate that a field's date is before #elem's date.</td>
</tr>
<tr>
<td>After date</td>
<td><code>data-afterdate="#elem"</code></td>
<td>Validate that a field's date is after #elem's date.</td>
</tr>
<tr>
<td>In list</td>
<td><code>data-inlist="foo, bar, foo bar"</code></td>
<td>
Validates that a field's value is present within the value list. You can define the delimiter using <code>data-inlist-delimiter=","</code>. Delimiter defaults to <code>","</code>.
</td>
</tr>
<tr>
<td>Luhn</td>
<td><code>data-luhn="true"</code></td>
<td>
Validates that a fields value passes the Luhn algorithm. Validates credit card numbers, as well as some other kinds of account numbers.
</td>
</tr>
</tbody>
</table>
</section>
<section>
<a name="integrations"></a>
Expand All @@ -1359,10 +1388,10 @@ <h3>Integration with other frameworks</h3>
</div>
<ul>
<li><a href="https://github.com/agiliq/django-parsley">Django</a></li>
<li><a href="https://github.com/mekishizufu/parsley-rails">Rails</a></li>
</ul>
</section>
<a href="#top" class="top pull-right">Top</a>

<hr>

<div class="footer">
Expand Down
1 change: 1 addition & 0 deletions i18n/_messages.en.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ window.ParsleyConfig = window.ParsleyConfig || {};
, digits: "This value should be digits."
, dateIso: "This value should be a valid date (YYYY-MM-DD)."
, alphanum: "This value should be alphanumeric."
, phone: "This value should be a valid phone number."
}
, notnull: "This value should not be null."
, notblank: "This value should not be blank."
Expand Down
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ <h1>Javascript forms validation.<br/><strong>Powerful, UX aware &amp; Dead simpl
<a class="btn btn-large call-to-action" href="documentation.html">See documentation &amp; examples</a>
</p>
<ul class="masthead-links">
<li><i class="icon-download-alt"></i>&nbsp;<a href="https://github.com/guillaumepotier/Parsley.js/archive/1.1.14.zip">Download</a></li>
<li>Version 1.1.14</li>
<li><i class="icon-download-alt"></i>&nbsp;<a href="https://github.com/guillaumepotier/Parsley.js/archive/1.1.15.zip">Download</a></li>
<li>Version 1.1.15</li>
</ul>
</div>

Expand Down
Loading

0 comments on commit 4157ec3

Please sign in to comment.