Or validator in conjunction with Validate::dbValues()

Or validator in conjunction with Validate::dbValues()

netenjoynetenjoy Posts: 4Questions: 2Answers: 0

i've a field of my table that i need to be populated with IDs from another table + an arbitrary value ("-1") that means "no record linked"

actually i use Serverside PHP validator ->validator(Validate::dbValues()) but oviusly this will not validate the arbitrary value, how can i add this "or condition"?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Hi,

    The dbValues() method does actually have the option of specifying extra values which are valid, which would do what you are looking for.

    The 5th parameter passed in can be an array of valid values as shown in the docs.

    Allan

  • netenjoynetenjoy Posts: 4Questions: 2Answers: 0

    Thanks,
    ->validator(Validate::dbValues(null,null,null,null,['-1'])) was what i was searching for.

This discussion has been closed.