• Ad Schellevis's avatar
    (mvc, add constraint pattern) for https://github.com/opnsense/core/issues/272 · 5361a64b
    Ad Schellevis authored
    Constraints hook into the default validations, new constraints should derive from BaseConstraint.
    This commit contains the code needed to add constraints to our model and a unittest for the UniqueConstraint option.
    
    Add the following to a model field, to force uniqueness for a combination of keys:
    
    <Constraints>
      <check001>                                                 <!--validation name, unique within this field-->
        <message>number should be unique</message>               <!--the message to output on validation failure -->
        <type>OPNsense\Base\Constraints\UniqueConstraint</type>  <!--the class to construct, derived from OPNsense\Base\Constraints\BaseConstraint -->
        <addFields>                                              <!--optional additional fields for the equation, defined in UniqueConstraint -->
           <field1>optfield</field1>
        </addFields>
      </check001>
    </Constraints>
    5361a64b
Name
Last commit
Last update
..
Constraints Loading commit data...
FieldTypes Loading commit data...
Menu Loading commit data...
Validators Loading commit data...
BaseModel.php Loading commit data...
BaseModelMigration.php Loading commit data...
ModelException.php Loading commit data...