Skip to content

Commit e84f376

Browse files
- definately removed data-API for parsley-API instead. Closes guillaumepotier#143
1 parent dfddcb3 commit e84f376

File tree

5 files changed

+25
-58
lines changed

5 files changed

+25
-58
lines changed

CHANGELOG.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
- [BC Break] Added `priorityEnabled` option (default true). Only show highest
66
priority failing validator error message. Validator structure altered in order
77
to manage priority
8-
- [BC Break] Now, custom DOM-API `parsley-` is supported and encouraged
8+
- [BC Break] added custom DOM-API `parsley-`. Previous data-API is dropped.
99
- Now to validate a form, use `parsley-validate`
1010
- Now to add a validator, use `parsley-<validator>`
11-
Previous data-API still supported for validators (not for `data-validate`,
12-
`data-value` and `data-bind`)
1311
- [BC Break] `onFormSubmit` is now called `onFormValidate`
1412

1513
**1.1.19**

TODO.md

+6-37
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,10 @@
1-
# new features
1+
# 1.2.x versions
22

3-
* create a error summary attached to form
4-
* Add native form sumbission parlsey(form).submit()
3+
- fix bugs
4+
- continuous improvement
55

6-
* [DONE] Add data API to set error messages (by form and by field)
7-
* [DONE] Existence in a dataSet
8-
* [DONE] Add minWords maxWords rangeWords validators
9-
* [DONE] Ajax check
10-
* [DONE] required on radio, checkboxes and selects
11-
* [NOPE] add special fields features: password stenght detector for example ?
12-
* [DONE] customize error template
13-
* [DONE] customize error messages placement
14-
* [DONE] customize error and success class names
15-
* [DONE] customize error and success class element
6+
# 2.x version
167

8+
- use AMD structure, more decoupled
9+
- use guillaumepotier/validator.js for validators
1710

18-
# refactos
19-
20-
* erroManagement bullshit function
21-
* [DONE] refacto ugly manageErrors() function
22-
* [DONE] stop binding `keypress` and `change` events by default. Must be passed as data
23-
arguments. By default, onSubmit validation only
24-
25-
26-
# enhancements
27-
28-
* Add typical use cases in documentation
29-
30-
* [DONE] focus on first or last error on form validation
31-
* [DONE] use `keypress` event when error detected and displayed, to hide it asap when field ok ?
32-
* [DONE] create API doc
33-
* [DONE] Do not bind twice keyup if set by user with data-trigger="keyup"
34-
35-
36-
# add / improve tests
37-
38-
* test that remote validator imply field has onchange event validation
39-
* [DONE] customization parsley classes (js & data api)
40-
* [DONE] customization errorClass handler (js & data api)
41-
* [DONE] customization error ul position (js & data api)

dist/parsley.min.js

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

parsley.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@
807807
return this.$element.domApi()[ 'value' ];
808808
}
809809

810-
return this.$element.data( 'value' ) || this.$element.val();
810+
return this.$element.val();
811811
}
812812

813813
/**
@@ -1359,7 +1359,7 @@
13591359
* @return {Mixed} public class method return
13601360
*/
13611361
$.fn.parsley = function ( option, fn ) {
1362-
var options = $.extend( true, {}, $.fn.parsley.defaults, 'undefined' !== typeof window.ParsleyConfig ? window.ParsleyConfig : {}, option, this.data(), this.domApi() )
1362+
var options = $.extend( true, {}, $.fn.parsley.defaults, 'undefined' !== typeof window.ParsleyConfig ? window.ParsleyConfig : {}, option, this.domApi() )
13631363
, newInstance = null;
13641364

13651365
function bind ( self, type ) {

tests/tests.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ var testSuite = function () {
148148
expect( $( '#hidden' ).hasClass( 'parsley-validated' ) ).to.be( false );
149149
expect( $( '#hidden' ).parsley( 'validate' ) ).to.be( null );
150150
} )
151-
it ( 'Should bind a DOM element with data-bind value set to true', function () {
151+
it ( 'Should bind a DOM element with parsley-bind value set to true', function () {
152152
expect( $( '#bindNonFormInput' ).hasClass( 'parsley-validated' ) ).to.be( true );
153153
} )
154154
} )
@@ -246,7 +246,7 @@ var testSuite = function () {
246246
triggerSubmitValidation( '#notnull', 'foo' );
247247
expect( $( '#notnull' ).hasClass( 'parsley-success' ) ).to.be( true );
248248
} )
249-
it ( 'required - data-api', function () {
249+
it ( 'required - parsley-api', function () {
250250
triggerSubmitValidation( '#required', '' );
251251
expect( $( '#required' ).hasClass( 'parsley-error' ) ).to.be( true );
252252
expect( getErrorMessage( '#required', 'required') ).to.be( 'This value is required.' );
@@ -493,7 +493,7 @@ var testSuite = function () {
493493
$( '#checkbox-mincheck2' ).attr( 'checked', 'checked' );
494494
expect( $( '#checkbox-mincheck1' ).parsley( 'validate' ) ).to.be( true );
495495
} )
496-
it ( 'mincheck data-group', function () {
496+
it ( 'mincheck parsley-group', function () {
497497
$( '#checkbox-mincheckgroup1' ).attr( 'checked', 'checked' );
498498
expect( $( '#checkbox-mincheckgroup1' ).parsley( 'validate' ) ).to.be( false );
499499
expect( getErrorMessage( '#checkbox-mincheckgroup1', 'mincheck') ).to.be( 'You must select at least 2 choices.' );
@@ -614,15 +614,15 @@ var testSuite = function () {
614614
} )
615615

616616
/***************************************
617-
override value with data-value
617+
override value with parsley-value
618618
***************************************/
619-
describe ( 'Override value with data-value' , function () {
620-
it ( 'required - data-value is empty, value is empty', function () {
619+
describe ( 'Override value with parsley-value' , function () {
620+
it ( 'required - parsley-value is empty, value is empty', function () {
621621
triggerSubmitValidation( '#datavalue1', '' );
622622
expect( $( '#datavalue1' ).hasClass( 'parsley-error' ) ).to.be( true );
623623
expect( getErrorMessage( '#datavalue1', 'required') ).to.be( 'This value is required.' );
624624
} )
625-
it ( 'required - data-value has value, value is empty', function () {
625+
it ( 'required - parsley-value has value, value is empty', function () {
626626
triggerSubmitValidation( '#datavalue2', '' );
627627
expect( $( '#datavalue2' ).hasClass( 'parsley-success' ) ).to.be( true );
628628
} )
@@ -689,7 +689,7 @@ var testSuite = function () {
689689
expect( getErrorMessage( '#requiredchanged1', 'required') ).to.be( 'required 1' );
690690
expect( getErrorMessage( '#requiredchanged2', 'required') ).to.be( 'required 2' );
691691
} )
692-
it ( 'Change error messages with data-api', function () {
692+
it ( 'Change error messages with parsley-api', function () {
693693
triggerSubmitValidation( '#requiredchanged3', '' );
694694
expect( getErrorMessage( '#requiredchanged3', 'required') ).to.be( 'custom required' );
695695

@@ -819,7 +819,7 @@ var testSuite = function () {
819819
$( '#alwaysValidate' ).parsley( 'validate' );
820820
expect( $( '#alwaysValidate' ).data( 'count' ) ).to.be( 3 );
821821
} )
822-
it ( 'Test data-trigger="change" on multiple inputs', function () {
822+
it ( 'Test parsley-trigger="change" on multiple inputs', function () {
823823
$( '#checkbox-maxcheck1' ).parsley( 'reset' );
824824
$( '#checkbox-maxcheck1' ).attr( 'checked', 'checked' );
825825
$( '#checkbox-maxcheck2' ).attr( 'checked', 'checked' );
@@ -910,7 +910,7 @@ var testSuite = function () {
910910
expect( $('#reset-textarea').hasClass('parsley-error')).to.be( false );
911911
})
912912
it ( 'test parsley dynamic add item', function () {
913-
$( '#dynamic-form' ).append( '<input type="text" data-type="email" class="dynamic-email" data-trigger="change" value="foo" />' );
913+
$( '#dynamic-form' ).append( '<input type="text" parsley-type="email" class="dynamic-email" parsley-trigger="change" value="foo" />' );
914914
var ParsleyForm = $( '#dynamic-form' ).parsley();
915915
expect( ParsleyForm.items.length ).to.be( 0 );
916916
expect( $( '#dynamic-form' ).parsley( 'validate' ) ).to.be( true );
@@ -947,7 +947,7 @@ var testSuite = function () {
947947
expect( $( '#onthefly' ).hasClass( 'parsley-error' ) ).to.be( false );
948948
expect( $( '#onthefly' ).hasClass( 'parsley-validated' ) ).to.be( false );
949949
} )
950-
it ( 'test setting custom error container within data-attributes', function () {
950+
it ( 'test setting custom error container within parsley-attributes', function () {
951951
expect( $( '#dataerrorcontainer-form' ).parsley( 'validate' ) ).to.be( false );
952952
expect( $( '#mycustomerrorcontainer ul.parsley-error-list' ).length ).to.be( 1 );
953953
} )

0 commit comments

Comments
 (0)