[midPoint] Validation for custom extended schema attributes
Ivan Noris
Ivan.Noris at evolveum.com
Fri Sep 23 13:49:36 CEST 2016
Hi Andreas,
I don't know of any better method than doing "validation" in object template as follows:
<mapping>
<name>Validate extension/publicPortalURL value</name>
<description>For all Organization objects. Regardless of type. If you don't need to validate, do not enter the virtual host. Warning: this is only simple validation.</description>
<source>
<path>$focus/extension/publicPortalURL</path>
</source>
<expression>
<script>
<code>
boolean isNew = com.evolveum.midpoint.model.common.expression.script.ScriptExpressionEvaluationContext.getThreadLocal().isEvaluateNew()
if (isNew && publicPortalURL != null) {
re = /^[a-zA-Z0-9-.]+$/
matcher = (publicPortalURL =~ re)
if (!matcher.matches())
throw new com.evolveum.midpoint.model.api.PolicyViolationException("Value for Public Portal Virtualhost " + publicPortalURL + " contains invalid characters.");
}
</code>
</script>
</expression>
</mapping>
It will throw "PolicyViolationException". Notice there is no target in the mapping.
Ivan
----- Original Message -----
> From: "Andreas Küstner" <andreas.kuestner at daasi.de>
> To: "midpoint" <midpoint at lists.evolveum.com>
> Sent: Friday, September 23, 2016 11:56:47 AM
> Subject: [midPoint] Validation for custom extended schema attributes
>
> Hello List!
>
> Is it possible to set own validation for the schema extension attributes
> via regex or something similar?
>
> Example:
>
> At import of csv file the fields of the column c2 should look like this
> : \d\d-*.-bb-\D\D\D = 99-Frankfurt-bb-Hbf
>
> And on the input field of the user it should also validate the value
> before it is send to the resource.
>
> Code could look something like this:
>
>
> <xsd:element name="custom_personal_number" type="xsd:string"
> minOccurs="0" maxOccurs="unbounded">
> <xsd:annotation>
> <xsd:appinfo>
> <a:indexed>true</a:indexed>
> <a:displayName>CustomPersonalNumber</a:displayName>
> <a:displayOrder>130</a:displayOrder>
> <a:help>The company personal number</a:help>
>
> <a:validation><![CDATA[\d\d-*.-bb-\D\D\D]]></a:validation>
> </xsd:appinfo>
> </xsd:annotation>
> </xsd:element>
>
>
>
>
> Thanks in advance!
> Andy
> _______________________________________________
> midPoint mailing list
> midPoint at lists.evolveum.com
> http://lists.evolveum.com/mailman/listinfo/midpoint
>
--
Ivan Noris
Senior Identity Engineer
evolveum.com
More information about the midPoint
mailing list