6 Replies Latest reply on Oct 10, 2011 10:15 PM by 831134

    Metadata Validation


      Can anyone point me to a resource for learning how to perform metadata validation?

      I have two custom metadata fields xStartDate and xEndDate - I don't want a user to be able to check in the content unless Start Date is before End Date.

      I have a custom metadata field called xContactEmail - I want to be able to check that the input is formatted as a valid email address.

      Thank you,
        • 1. Re: Metadata Validation
          Create a component with a filter on 'validateCheckinData'. Point to a Java Class where you do something like below:
          public class MyValidation implements FilterImplementor {
            public int doFilter ( Workspace ws, DataBinder binder, ExecutionContext ctx ) {
              String myStartDate = binder.getLocal( "xStartDate" );
              String myEndDate = binder.getLocal( "xEndDate" );
              String myEmail = binder.getLocal( "xContactEmail" );
              if ( isNotBetweenDates( myStartDate, myEndDate ) ) {
                 m_binder.putLocal( "StatusMessage", "not between " + myStartDate + " and " + myEndDate );
                 return ABORT;
              } else if ( isNotValidEmail( myEmail ) ) {
                 m_binder.putLocal( "StatusMessage", myEmail + " is not valid email" );
                 return ABORT;
              return CONTINUE;
          See HowTo components for how to set up your component and other samples.
          1 person found this helpful
          • 2. Re: Metadata Validation
            Alternatively, you could also try iDocScript and profiles - see an example at http://download.oracle.com/docs/cd/E17904_01/doc.1111/e10978/c04_metadata.htm#CSMRC573
            1 person found this helpful
            • 3. Re: Metadata Validation

              I tried the example that they provided with a few minor changes:

              1. I used one of my custom content types
              2. I used one of my custom rules that is NOT global

              Content server allowed the check-in and didn't go to any error page... not really sure how to trouble shoot this.

              Have you had success with this?

              • 4. Re: Metadata Validation
                Those solutions are all server side - after the form is submitted. That's a bad user experience.
                I suggest you add some JavaScript to the checkin form that prevents submission when validation fails. You can throw an alert or better still, highlight the bad form data.
                I uh, don't know of an online example but any web dude could write the JavaScript.
                • 5. Re: Metadata Validation
                  I'm afraid the profiles work "as is". In general, I agree with my predecessor - validations, or at least validations that you can do like that (for instance, I wrote a component for "quotas", as a filter, which can hardly not to be server-side), should be client-side, not server-side. So, if you go with customizations, Java-script is probably the first option.
                  • 6. Re: Metadata Validation
                    We've done something in the past that used AJAX/JQuery client side to perform validation. Just extend the include to call your function(s) as needed.