Hi Mathijs,
Sorry, didn't have time to follow up on this before...
This rule type allows me to do something, but only with widgets.
Not sure whether that is what I always want, or is sufficient, but for the
particular example I gave it might work.
Unfortunately the documentation
(http://www.hippocms.org/display/CMS/Template+validation) leaves me guessing a
bit.
This is what I read/hope/assume:
An arbitrary xpath expression can be used in lookupWidget?
(In my case I would need the widget located at something to the likes of:
"../preceding-sibling[header/@level!=''][last()]/header/@level".
Thus far, haven't been able to make it work, while it does work on an XML
document.)
The xpath search is performed on the XML document I am editing. Exact or
something looking like it?
And finally that lookupWidget returns a widget only and only if
1. xpath selects a single XML node.
2. that node happens to have a widget associated with it.
and otherwise it returns null?
Thanks,
Reinier
Mathijs Brand wrote:
Hi Reinier,
Here's a business rule for a picture that checks if a checkbox
"on_homepage" was checked.
If it is checked, then a picture the field is required otherwise it is
not. I think you could use this to do what you're trying to do.
<rule for="/document/content/picture">
<picker id="asset"/>
<validation>
<validator name="javascript">
<![CDATA[
var barWidget =
lookupWidget(widget,"/document/meta/on_homepage");
if (barWidget != false){
if (barWidget.value != false && (widget.value == null ||
widget.value.length() <= 0)){
setValidationError(widget,"A pictue is required when on
homepage is checked.");
return false;
}
}
clearValidationError(widget); // clear previous validation
errors
return true;
]]>
</validator>
</validation>
</rule>
Kind regards,
Mathijs Brand
Hippo
[EMAIL PROTECTED]
Amsterdam - Hippo B.V. Oosteinde 11 1017 WT Amsterdam +31(0)20-5224466
San Francisco - Hippo USA Inc. 101 H Street, suite Q Petaluma CA
94952-3329 +1 (707) 773-4646
www.onehippo.com [EMAIL PROTECTED]
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Reinier
van den Born
Sent: maandag 8 september 2008 12:14
To: Hippo CMS development public mailinglist
Subject: [HippoCMS-dev] Validating documents as a whole
Hello all,
Hippo CMS provides the possibility to add postprocessing when saving a
document.
But is there also a way to sort of "postvalidate"?
I mean, I can validate fields (eg. being required), and have the
document rejected when I try to save.
As part of that mechanism I would like to be able to define some
validation on the document as a whole.
For instance:
I have documents with a sequence of paragraphs, each paragraph having a
header and a header level.
I would like to validate a proper nesting of levels. So no level 3
directly following a level 1 header, etc.
Is there already some way to do this?
Otherwise, can someone suggest a direction to find a solution?
Reinier
--
Reinier van den Born
HintTech B.V.
Rotterdamseweg 183c, 2629 HD Delft
T: +31(0)15 268 2573
F: +31(0)15 268 2567
M: +31(0)6 494 171 36
--
HintTech levert specialisten op het gebied van softwareontwikkeling (.NET en
Java),
projectmanagement, informatiebeveiliging en business consulting.
KvK Den Haag nr. 27242282 | BTW nr. NL8062.16.396.B01
begin:vcard
fn:Reinier van den Born
n:van den Born;Reinier
org:HintTech B.V.
adr:;;Rotterdamseweg 183c;Delft;;2629HD;Netherlands
email;internet:[EMAIL PROTECTED]
tel;work:+31-15-268 2573
tel;fax:+31-15-268 2567
tel;cell:+31-6 494 171 36
note;quoted-printable:KvK Den Haag nr. 27242282 | BTW nr. NL8062.16.396.B01=0D=0A=
=0D=0A=
HintTech levert specialisten op het gebied van softwareontwikkeling (.NET=
en Java), projectmanagement, informatiebeveiliging en business consulting=
.=0D=0A=
=0D=0A=
url:www.hinttech.com
version:2.1
end:vcard
********************************************
Hippocms-dev: Hippo CMS development public mailinglist
Searchable archives can be found at:
MarkMail: http://hippocms-dev.markmail.org
Nabble: http://www.nabble.com/Hippo-CMS-f26633.html