Featured On ...

asp.net

totalasp.co.uk

fuzzysoftware.com

devdex.com

123aspx.com

dotnetfreaks.com

411asp.net

and more ...

Release notes for the ASP.NET Validator package v1.3

A number of improvements occurred for version 1.3 of the ASP.NET Validator package over the 1.2 release. Among these are the very valuable inline message functions which allow the developer to embed both built-in as well as user defined properties into the message text.

The following table lists the features that have been added to the 1.3 release. For a quite thorough demonstration of these new features as well as code samples, see demo 7 and demo 8.

Type Title/Issue Description
Change Strict year in date formats. Version 1.2 forced date entry to contain a 4 digit year. This restriction has been lifted. Dates entered in such formats as yyyy/mm/dd can now contain a 2 digit year.
Bug Commas being rejected in integer fields. Commas were being rejected in fields that were being validated as integers and this was causing validation to fail. This has been fixed.
Bug Unable to validate domains starting with a number. The ValidatorEntryDomain had a problem where domain names that started with a numeric character were being validated incorrectly. This has been fixed. This problem affected the classes ValidatorEntryEmail, ValidatorEntryUrl and ValidatorEntryDomain.
Bug Comparer failing. In certain situations the comparer classes were failing. This has been fixed. This problem affected ValidatorEntryComparer, ValidatorEntryNumericComparer, ValidatorEntryDateComparer and ValidatorEntryTextComparer.
Feature Comparer extended. A need became apparent to extend the comparer classes to compare not just two fields, but also one field and a literal value. This has been added to all ValidatorEntryComparer subclasses.
Feature Inline message functions. This new feature allows built-in and user-defined properties to be embedded into message strings. Developers embed these properties by placing {expression} (using curly braces) inside the message text. The type of expression inside the curly braces is very flexible and can be a combination of properties and functions. The result of the expression is embedded in the message. For a full list of functions and properties currently available, please scroll to the bottom of this page, or click here.
Feature Associative arrays in inline message function blocks. It is currently possible to create associative arrays within the inline message blocks using the following syntax: [key1 => value1, key2 => value2, ..., keyn => valuen]. Associative arrays are also represented by select lists, radio button lists and checkbox lists. Associative arrays represented by these field types are referenced by the property names allvalues and selectedvalues. Full support for these associative arrays hass been built into the inline message block processing.
Feature Support for CheckBoxList Version 1.2 of the validator package did not support the CheckBoxList web control. Support for this control has been added in 1.3.
Feature Simplification of the ValidatorEntryAnd and ValidatorEntryOr classes. The ValidatorEntryAnd and ValidatorEntryOr classes in version 1.2 of the validator package require a number of lines of code in order to build a complex validation expression. The constructors of these classes have been simplified for this purpose.
Feature Count validator. This validator (ValidatorEntryCount) validates against a specific number of items in a collection (for example, inside a select list). This validator uses the ComparisonMethod constants used by the ValidatorEntryComparer class to compare against the count.
Feature N-Valid validator. This validator (ValidatorEntryNValid) takes one or more ValidatorEntry objects and counts how many of the validators have passed validation. When it has the count available, it makes a comparison of the count against a specified number and one the ComparisonMethod constants.
Feature N-Required validator. This validator (ValidatorEntryNRequired) is similar to, and extends, the ValidatorEntryNValid class except that rather than allowing any type of validation it specifically counts those that are non-blank using the ValidatorEntryRequired validator on each field. Again, this validator uses the ComparisonMethod constants used by the ValidatorEntryComparer class to compare against the count.
Feature Word count validator. This validator (ValidatorEntryWordCount) validates a field that has a specific number of words in it. This class is an extension of the ValidatorEntryCount validator class and hence uses the ComparisonMethod constants to make the comparison.
Change Changed CompareMethod to ComparisonMethod. This enumeration was causing a naming conflict in VB.NET so its name was changed to ComparisonMethod.
Change More thorough documentation. The documentation for the entire ASP.NET Validator package has been updated. With version 1.2, no documentation was shipped with the control, instead it was expected that users use the online documentation. In the 1.3 release, the documentation, as well as being updated, is shipped with the control so that users do not need to consult the website manual. NOTE: As of the release of version 1.3, some but not all of the documentation has been included in the package. The remaining documentation needs to be retrieved from this website. The remaining documentation will be migrated into the release package shortly.
Feature Culture sensitive. Version 1.2 of the validator was not culture sensitive. Culture sensitivity has been included in the 1.3 release. Users can now specify RFC 1766 style culture names using a new validatorCulture property in the web.config file or when not used, the validator will adopt the default culture of the server. The culture sensitivity affects both date and time validation on the client and on the server.
Change Removed zip from email. Some users reported difficulty in receiving the email that includes the zip attachment. As a result the zip package will no longer be included in the email, rather it will need to be downloaded separately from the "Try it or buy it" page.
Change New constructors. In Version 1.2, the ValidatorEntry classes contained a number of inconsistent constructors. New constructors have been added in version 1.3. The old constructors are now deprecated and will be removed in entirely version 1.4.
Change Some static methods and properties turned into instance method and properties. In order to make the declaration of methods consistent in the Validator class, some of the static method and properties were made instance method and properties.

Inline message blocks

Inline message blocks are embedded in the message text as in the following example:

Validator v = Validator.Current;
v.Add(new ValidatorEntryWordCount(ValWordCount, "{switch(count > 6, [true => 'The text', default => value])} does not contain {n} words. It contains {count} {switch(count, [1 => 'word', default => 'words'])}.", ComparisonMethod.EqualTo, 4));

The following table show the properties that are available within inline message blocks for each ValidatorEntry subclass:

Class Properties
ValidatorEntryAnd None.
ValidatorEntryCount value, textvalue, count, operator, n, usepercent, delimiter, includeemptystrings, required, percentage.
ValidatorEntryDate value, textvalue, format, required.
ValidatorEntryDateComparer value1, value2, textvalue1, textvalue2, format, difference, operator.
ValidatorEntryDateRange value, textvalue, format, min, max, required.
ValidatorEntryDomain value, textvalue, required.
ValidatorEntryEmail value, textvalue, required.
ValidatorEntryFloat value, textvalue, required.
ValidatorEntryFloatRange value, textvalue, min, max, required.
ValidatorEntryInt value, textvalue, required.
ValidatorEntryIntRange value, textvalue, min, max, required.
ValidatorEntryNRequired count, operator, n, usepercent, required, total.
ValidatorEntryNumericComparer value1, value2, textvalue1, textvalue2, difference, operator.
ValidatorEntryNValid count, operator, n, usepercent, required, total.
ValidatorEntryOr None.
ValidatorEntryRegex value, textvalue, re, required.
ValidatorEntryRequired value, textvalue, required.
ValidatorEntryTextComparer value1, value2, textvalue1, textvalue2, difference, operator.
ValidatorEntryTextLength value, textvalue, required.
ValidatorEntryUrl value, textvalue, required.
ValidatorEntryWordCount value, textvalue, count, operator, n, usepercent, delimiter, includeemptystrings, required, percentage.

The following table show the functions that are available within inline message blocks. Note that complete documentation for inline message blocks can be found in the documentation section of this website.

Name Description Status
uc(str) Returns an uppercase copy of the input string. Complete.
lc(str) Returns a lowercase copy of the input string. Complete.
ucfirst(str) Returns a copy of the input string where the first letter of each word is uppercase and the remaining letters of each word is lowercase. Complete.
slice(array, beginIndex[, endIndex]) Creates a new associative array using the elements the source array starting from beginIndex and ending at endIndex or the end of the source array if no endIndex is provided. Complete.
join(array, delimiter1[, delimiter2[, template]]) Joins the keys and or values of the associative array using the specified delimiters and template. If a second delimiter is supplied, it is used to join the last two elements of the array. If a template is supplied, it must contain a string that defines how each element is displayed in the output string. For example, if the template were '{value} ({key})', then each element in the joined string would adhere to that format where '{key}' would be replaced by the key and '{value}' would be replaced by the value. Complete.
switch(key, array) Searches for the key in the associative array and returns the value associated with that key. If the key cannot be found, the function looks for the key '*' and returns its associated value. If '*' cannot be found, null is returned. The key passed into this function can be either a boolean, a number or a string. Complete.
length(str | array) Returns the length of the string or the array passed to this function. Complete.
cint(value) Attempts to convert the value to an integer. If the conversion fails, the orginal value is returned. Complete.
cdbl(value) Attempts to convert the value to an double value. If the conversion fails, the orginal value is returned. Complete.
cstr(value) Attempts to convert the value to a string. Complete.
cdate(value[, format]) Attempts to convert the value to a date using, if specified, the format. The format specifier follows the same rules as the ValidatorEntryDate.Format and can be 'YYYYMMDD', 'YYYYDDMM', 'MMDDYYYY' or 'DDMMYYYY'. If the conversion fails, the orginal value is returned. Complete.
formatNumber(value, format) First attempts to convert the value to a number then if that succeeds, formats it according to the format string. The format string follows the same rules as Microsoft's Custom Number Format Strings. If the value cannot be converted to a number, it is returned as is. Complete.
formatDate(date, format) This function formats the date value following the same rules as Microsoft's Custom Date Time Strings. If value passed in is not a Date object (DateTime on the server), the orginal value is returned. To ensure that the input string is a date type, use cdate(...) to convert the date string you are formatting. Complete.
isbool(value) Returns true if the value represents a boolean. Complete.
isint(value) Returns true if the value can be converted to an integer. Complete.
isdbl(value) Returns true if the value can be converted to a double value. Complete.
isdate(value[, format]) Returns true if the value can be converted to a date using the same rules as cdate(...). Complete.
concat(value1[, value2[, ...[, valuen]]]) Concatenates all values as strings and returns the result. Complete.

© 2002 - 2008 Copyright, Disclaimer and Privacy Statement