Skip to content

Commit

Permalink
Version up, doc regenerated, js tests adjusted to pass when run with …
Browse files Browse the repository at this point in the history
…latest dependencies.
  • Loading branch information
jwaliszko committed Oct 14, 2015
1 parent 53262ff commit 2e59fd8
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 20 deletions.
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,15 @@ Priority - Gets or sets the hint, available for any concerned external
others of its kind, i.e. ExpressiveAttribute. Value is optional and not
set by default, which means that execution order is undefined.
ErrorMessage - Gets or sets an explicit error message string. A difference to default
behavior is awareness of new format specifiers, given in curly brackets,
used to extract values of specified fields, e.g. {field}, {field.field}
within current model context. Braces can be escaped by double-braces,
i.e. to output a { use {{ and to output a } use }}. The same logic works
for messages provided in resources.
behavior is awareness of new format items, i.e. {fieldPath[:indicator]}.
Given in curly brackets, can be used to extract values of specified
fields, e.g. {field}, {field.field}, within current model context or
display names of such fields, e.g. {field:n}. Braces can be escaped by
double-braces, i.e. to output a { use {{ and to output a } use }}. The
same logic works for messages provided in resources.
```

Full API documentation *(probably not useful at all, since the note above covers almost exhaustively what is actually needed to work with EA)* generated with [Sandcastle](https://sandcastle.codeplex.com/) (with the support of [SHFB](http://shfb.codeplex.com/)), can be downloaded in the form of compiled HTML help file from [here](doc/api/api.chm?raw=true) (only C# API, no JavaScript there).
Full API documentation *(probably not much useful, since the note above covers almost exhaustively what is actually needed to work with EA)* generated with [Sandcastle](https://sandcastle.codeplex.com/) (with the support of [SHFB](http://shfb.codeplex.com/)), can be downloaded in the form of compiled HTML help file from [here](doc/api/api.chm?raw=true) (only C# API, no JavaScript there).

#####<a id="implementation">Implementation</a>

Expand Down Expand Up @@ -405,12 +406,21 @@ If you need to handle value string extracted from DOM field in any non built-in
```JavaScript
<script>
ea.addValueParser('customparser', function(value, field) {
// parameters: value - raw data string extracted by default from DOM element,
// parameters: value - raw data string extracted by default from DOM element
// field - DOM element name for which parser was invoked
return ... // handle exctracted field value string on your own
});
```

Finally, there is a possibility to override the default parser without the `ValueParser` annotation - use the type name for parser registration, e.g.
```
<script>
ea.addValueParser('numeric', function (value) {
return ... // handle global numeric parsing on your own
});
```
If you redefine default parsing mechanism, you can still have the `ValueParser` annotation on any fields you consider exceptional - annotation gives highest parsing priority.

#####<a id="how-to-cope-with-dates-given-in-non-standard-formats">How to cope with dates given in non-standard formats?</a>

When values of DOM elements are extracted, they are converted to appropriate types. For fields containing date strings, JavaScript `Date.parse()` method is used by default. As noted in [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse), the input parameter is:
Expand Down
Binary file modified doc/api/api.chm
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.4.2.0")]
[assembly: AssemblyFileVersion("2.4.2.0")]
[assembly: AssemblyVersion("2.4.3.0")]
[assembly: AssemblyFileVersion("2.4.3.0")]
6 changes: 3 additions & 3 deletions src/ExpressiveAnnotations.MvcWebSample/Views/Home/Home.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@
// expann.addMethod... // do something with ExpressiveAnnotations
// ea... // do something with original ea variable
// ----- define settings -----
// ----- define your settings -----
ea.settings.apply({
debug: '@debug' === 'true',
dependencyTriggers: '@triggers' // if not explicitly provided, default setup is: 'change keyup'
});
// ----- define parsers -----
// ----- define your parsers -----
ea.addValueParser('NonStandardDateParser', function(value) { // override default datetime parsing mechanism to deal with yyyy-mm-dd format
if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) { // in case the value does not have non-standard format (here, when language set to english)...
Expand All @@ -75,7 +75,7 @@
: array; // otherwise - return array object for the ArrayLength method to work on
});
// ----- define methods -----
// ----- define your methods -----
ea.addMethod('IsBloodType', function(group) {
return /^(A|B|AB|0)[\+-]$/.test(group);
Expand Down
4 changes: 2 additions & 2 deletions src/ExpressiveAnnotations/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.3.3.0")]
[assembly: AssemblyFileVersion("2.3.3.0")]
[assembly: AssemblyVersion("2.3.4.0")]
[assembly: AssemblyFileVersion("2.3.4.0")]
6 changes: 3 additions & 3 deletions src/expressive.annotations.validate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* expressive.annotations.validate.js - v2.6.3
/* expressive.annotations.validate.js - v2.6.4
* Client-side component of ExpresiveAnnotations - annotation-based conditional validation library.
* https://github.com/JaroslawWaliszko/ExpressiveAnnotations
*
Expand Down Expand Up @@ -36,7 +36,7 @@ var
}, // func - parse logic
// e.g. for objects when stored in non-json format or dates when stored in non-standard format (not proper for Date.parse(dateString)),
// i.e. suppose DOM field date string is given in dd/mm/yyyy format:
// ea.addValueParser('dateparser', function(value, field) { // parameters: value - raw data string extracted by default from DOM element,
// ea.addValueParser('dateparser', function(value, field) { // parameters: value - raw data string extracted by default from DOM element
// // field - DOM element name for which parser was invoked
// var arr = value.split('/'); return new Date(arr[2], arr[1] - 1, arr[0]).getTime(); // return milliseconds since January 1, 1970, 00:00:00 UTC
// });
Expand Down Expand Up @@ -364,7 +364,7 @@ var
}
parseFunc = typeHelper.findValueParser(field, type); // custom type-specific parser lookup - secondary parsing priority
if (!parseFunc.error) {
logger.warn(typeHelper.string.format('Overriden {0} type parsing runs for {1} field. All fields of {0} type are going to be parsed using your value parser. If such a behaviour is unintentional, change the name of your value parser to one, which does not indicate at {0} (or any other) type name.', type, field));
logger.warn(typeHelper.string.format('Overriden {0} type parsing runs for {1} field. All fields of {0} type are going to be parsed using your value parser. If such a behavior is unintentional, change the name of your value parser to one, which does not indicate at {0} (or any other) type name.', type, field));
return parseFunc(value, field);
}
return typeHelper.tryAutoParse(value, type); // built-in parser lookup - lowest parsing priority
Expand Down
5 changes: 2 additions & 3 deletions src/expressive.annotations.validate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
(function($, qunit, ea, eapriv) {
// equal( actual, expected [, message ] )

// qunit.testDone(function() { // reset state for further tests if needed
// });

qunit.module("type helper");

qunit.test("verify_array_storage", function() {
Expand Down Expand Up @@ -644,6 +641,8 @@
});

var validator = $('#basic_test_form').validate();
validator.settings.ignore = ''; // enable validation for hidden fields (our entire test form is hidden) http://stackoverflow.com/q/8466643/270315

var element = $('#basic_test_form').find('[name="ContactDetails.Email"]');
var result = element.valid(); // trigger wait for result (all is synchronous)
qunit.ok(!result);
Expand Down
8 changes: 8 additions & 0 deletions src/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,17 @@
</div>

<script src="qunit-1.18.0.js"></script>

<!-- test with earliest compatible versions declared -->
<script src="./packages/jQuery.1.8.2/Content/Scripts/jquery-1.8.2.js"></script>
<script src="./packages/jQuery.Validation.1.10.0/Content/Scripts/jquery.validate.js"></script>
<script src="./packages/Microsoft.jQuery.Unobtrusive.Validation.3.1.1/Content/Scripts/jquery.validate.unobtrusive.js"></script>

<!-- in addition test with latest stable releases -->
<!--<script src="https://cdn.jsdelivr.net/jquery/latest/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/jquery.validation/latest/jquery.validate.min.js"></script>
<script src="https://cdn.jsdelivr.net/jquery.validation.unobtrusive/latest/jquery.validate.unobtrusive.min.js"></script>-->

<script src="expressive.annotations.validate.js"></script>
<script src="expressive.annotations.validate.test.js"></script>
</body>
Expand Down

0 comments on commit 2e59fd8

Please sign in to comment.