Menu

Can XML configuration contain possible values for field?

2018-02-28
2018-03-04
  • Kieth Skowran

    Kieth Skowran - 2018-02-28

    Didn't see this in example, so:
    If I use an XML file to configure my validator, can it contain the valid values for the field?
    Like this maybe:
    <class type="acme.model.Room" overwrite="false" applyFieldConstraintsToSetter="true">

    <field name="name">
      <length min="4" max="23" />
      <values "Alpha|Beta|Delta" />
    </field>
    
     
  • Seb

    Seb - 2018-03-04

    hi Kieth,

    try this:

    <field name="name">
      <length min="4" max="23" />
      <memberOf>
        <members>
          <string>Alpha</string>
          <string>Beta</string>
          <string>Delta</string>
        </members>
      </memberOf>
    </field>
    

    Btw. the easiest way to figure out how constraints are configured via XML is to use an editor that supports XSD auto-completion (e.g. Eclipse) and specifying the oval config XSD in the XML header like

    <?xml version="1.0" ?>
    <oval
      xmlns="http://oval.sf.net/oval-configuration"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://oval.sf.net/oval-configuration http://oval.sourceforge.net/oval-configuration.xsd">
    
     </oval>
    

    Regards,
    Seb

     

    Last edit: Seb 2018-03-04

Log in to post a comment.