Uploaded image for project: 'MidPoint'
  1. MidPoint
  2. MID-6928

Form validation (object template) is always checking also previous value of attribute - making it impossible to fix invalid value

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 4.0.3
    • Fix Version/s: 4.6
    • Component/s: GUI
    • Labels:
    • Subscription:
      Internal

      Description

      I'm using the form validation using <item> in object template:

          <item>
              <c:ref>telephoneNumber</c:ref>
              <help>Mobile Telephone Number</help>
              <validation>
                  <server>
                      <expression>
                          <trace>true</trace>
                          <script xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3" xsi:type="c:ScriptExpressionEvaluatorType">
                              <code>
                              import java.util.regex.Matcher
                              import java.util.regex.Pattern
                              import com.evolveum.midpoint.schema.result.OperationResult
                              import com.evolveum.midpoint.schema.result.OperationResultStatus
                   
                              if (input == null) {
                                  return null
                              }
                              
                              
                              
                              if (midpoint.isEvaluateNew() &amp;&amp; input != null) {
          List conflicts = midpoint.getObjectsInConflictOnPropertyValue(object, "telephoneNumber", input, "stringIgnoreCase", true)
          if (!conflicts.isEmpty()) {
          //    throw new com.evolveum.midpoint.util.exception.PolicyViolationException("Telephone number: " + telephoneNumber + " already used; conflicting object(s): " + conflicts);
          
          def aaa=''
          for (u in conflicts) {
              aaa = aaa + u?.name;
          }
                              result = new OperationResult("Validate telephone number");
                              result.setMessage("Telephone number already used by" + aaa);
                              result.setStatus(OperationResultStatus.FATAL_ERROR)
                   
                              return result.createOperationResultType();
          }
      }
      
      <!-- TODO uncomment for syntax validation -->
      /*             
                              match = (input ==~ "^555-[0-9]{4}\$")
                         if (match) {
                                return null
                              }
                   
                              result = new OperationResult("Validate telephone number");
                              result.setMessage("Telephone number must be 555-xxxx");
                              result.setStatus(OperationResultStatus.FATAL_ERROR)
                   
                              return result.createOperationResultType();
        */           
                         </code>
                          </script>
                      </expression>
                  </server>
              </validation>
          </item>
      

      The problem is that if user already has invalid value of attribute (telephoneNumber) - before this validation was used in midPOint - I cannot get rid of it. The validation is simply used also for the old value when doing either reconcile or even completely different change of different attribute.

      I've tried with only syntax validation (no uniqueness) and also with the old way of mapping with no target and expression throwing PolicyViolationException - all behaviour is the same.

      I need to check this is 4.3-SNAPSHOT.

        Attachments

          Activity

            People

            Assignee:
            katkav Katka Bolemant
            Reporter:
            vix Ivan Noris
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: