baibaratsky / php-webmoney

WebMoney API PHP Library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Create new validation rule when one parameter is non mandatory if other is specified

vitalijssilins opened this issue · comments

There is need of validation rule, when one parameter becomes non-mandatory if other parameter is specified.

Example:
payment/purse and payment/phone parameters in WMC1 interface:
https://wiki.webmoney.ru/projects/webmoney/wiki/%D0%98%D0%BD%D1%82%D0%B5%D1%80%D1%84%D0%B5%D0%B9%D1%81_WMC1

@kotchuprik Validators is your area, so do anything please ;)

I think we can try to use TYPE_DEPEND_REQUIRED rule. @vitalijssilins could you try something like this?

protected function getValidationRules()
{
  return array(
    RequestValidator::TYPE_DEPEND_REQUIRED => array(
          'purse' => array('phone' => array('')),
          'phone' => array('purse' => array('')),
    ),
  );
}

I'm sure that this looks not fine but also I'm not sure that we need to do yet validation rule if this will be working.

Example for using depend required rule here.