baibaratsky / php-webmoney

WebMoney API PHP Library
Other
73 stars 32 forks source link

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

Closed vitalijssilins closed 7 years ago

vitalijssilins commented 8 years ago

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

baibaratsky commented 8 years ago

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

chuprik commented 8 years ago

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.