Livevalidation Macros
![]() | Wiki macros implementation of the LiveValidation javascript framework (http://livevalidation.com/documentation) to be used with validation specified in XWiki classes. |
Type | XAR |
Category | |
Developed by | |
Active Installs | 3 |
Rating | |
License | GNU Lesser General Public License 2.1 |
Table of contents
Description
Wiki macros implementation of the LiveValidation javascript framework to be used with validation specified in XWiki classes.
Macros
{{livevalidation /}} | Provides client-side live validation of a single XObject based on the validation expressions and messages defined in its XClass. |
{{livevalidationConfirmation /}} | Validates that another field of the form match the value of an XObject property. |
{{livevalidationCustom /}} | Validates a XObject property value using a custom remote XWiki document that should returns "true" when valid or "false" when not valid, based on the field value and the property reference. |
{{livevalidationEmail /}} | Validates that XObject property value is a valid email address. |
{{livevalidationFormat /}} | Validates that XObject property value against a regular expression. |
{{livevalidationPresence /}} | Validates that XObject property value is present (ie. not null, undefined, or an empty string). |
Usage
{{livevalidationConfirmation form="formId" property="propertyReference" match="fieldId" failureMessage="A message to display when validation fail" /}}
{{livevalidationCustom form='formId' property='propertyReference' against='validationDocumentReference' failureMessage='Invalid value.'/}}
{{livevalidationEmail form='formId' property='propertyReference' failureMessage='Email format invalid.' /}}
{{livevalidationFormat form='formId' property='propertyReference' pattern='[A-Z]+' failureMessage='Only uppercase characters allowed.' /}}
{{livevalidationPresence form='formId' property='propertyReference' failureMessage='Non empty value required.' /}}
{{livevalidation /}}
Param | Description |
---|---|
form | Unique ID of the form html element that will be validated before submission (Optional, default to inline). |
object | Object reference of the XObject to be validated. |
{{livevalidationConfirmation /}}
Param | Description |
---|---|
form | Unique ID of the form html element that contains the validated field (Optional, default to inline). |
property | Property reference of the field to be validated. |
match | Identifier of the field that should match the property value. |
failureMessage | Message to be used upon validation failure. |
{{livevalidationCustom /}}
Param | Description |
---|---|
form | Unique ID of the form html element that contains the validated field (Optional, default to inline). |
property | Property reference of the field to be validated. |
against | Document reference of the document that will be AJAX requested to settle the validation. |
args | Additional QueryString passed over to the requested document with the property reference and the field value. |
failureMessage | Message to be used upon validation failure. |
{{livevalidationEmail /}}
Param | Description |
---|---|
form | Unique ID of the form html element that contains the validated field (Optional, default to inline). |
property | Property reference of the field to be validated. |
failureMessage | Message to be used upon validation failure. |
{{livevalidationFormat /}}
Param | Description |
---|---|
form | Unique ID of the form html element that contains the validated field (Optional, default to inline). |
property | Property reference of the field to be validated. |
pattern | A regular expression pattern in Javascript syntax. |
failureMessage | Message to be used upon validation failure. |
{{livevalidationPresence /}}
Param | Description |
---|---|
form | Unique ID of the form html element that contains the validated field (Optional, default to inline). |
property | Property reference of the field to be validated. |
failureMessage | Message to be used upon validation failure. |
Examples
Add the following lines to MyApp.MyAppSheet:
{{livevalidationConfirmation property='MyApp.MyAppClass[0].myprop' match='fieldId' failureMessage='This field should match myprop.' /}}
{{livevalidationCustom property='MyApp.MyAppClass[0].myprop' against='Code.IsUniqueValidator' failureMessage='myprop is required to be unique.' /}}
{{livevalidationEmail property='MyApp.MyAppClass[0].myprop' failureMessage='Email format is invalid.' /}}
{{livevalidationFormat property='MyApp.MyAppClass[0].myprop' pattern='/^[A-Z]*$/' failureMessage='myprop must contain only uppercase characters.' /}}
{{livevalidationPresence property='MyApp.MyAppClass[0].myprop' failureMessage='myprop cannot be empty.' /}}√
Prerequisites & Installation Instructions
We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager). Note that installing Extensions when being offline is currently not supported and you'd need to use some complex manual method.
You can also use the following manual method, which is useful if this extension cannot be installed with the Extension Manager or if you're using an old version of XWiki that doesn't have the Extension Manager:
- Log in the wiki with a user having Administration rights
- Go to the Administration page and select the Import category
- Follow the on-screen instructions to upload the downloaded XAR
- Click on the uploaded XAR and follow the instructions
- You'll also need to install all dependent Extensions that are not already installed in your wiki
Dependencies
Dependencies for this extension (org.xwiki.contrib.livevalidation:livevalidation-macros 1.2):
- org.xwiki.platform:xwiki-platform-rendering-wikimacro-api 3.5.1
- org.xwiki.platform:xwiki-platform-oldcore 3.5.1
- org.xwiki.platform:xwiki-platform-query-manager 3.5.1
- org.xwiki.platform:xwiki-platform-model 3.5.1
- org.xwiki.platform:xwiki-platform-skin-skinx 3.5.1
- org.xwiki.platform:xwiki-platform-rendering-macro-velocity 3.5.1
- org.xwiki.platform:xwiki-platform-rendering-macro-include 3.5.1
- org.xwiki.rendering:xwiki-rendering-macro-html 3.5.1