| @@ 469-476 (lines=8) @@ | ||
| 466 | ; |
|
| 467 | ||
| 468 | $customOnlyFields = ['business_logo', 'business_name', 'business_primary_color', 'business_url', 'legal_entity', 'product_description', 'support_email', 'support_phone', 'support_url']; |
|
| 469 | foreach ($customOnlyFields as $field) { |
|
| 470 | $rootNode->validate() |
|
| 471 | ->ifTrue(function ($v) use ($field) { |
|
| 472 | return isset($v['type']) && Account::TYPE_CUSTOM !== $v['type'] && isset($v[$field]); |
|
| 473 | }) |
|
| 474 | ->thenInvalid("You can only set \"$field\" for custom accounts.") |
|
| 475 | ->end(); |
|
| 476 | } |
|
| 477 | ||
| 478 | $forbiddenForStandardAccounts = ['debit_negative_balances', 'decline_charge_on', 'payout_schedule', 'payout_statement_descriptor']; |
|
| 479 | foreach ($forbiddenForStandardAccounts as $field) { |
|
| @@ 479-486 (lines=8) @@ | ||
| 476 | } |
|
| 477 | ||
| 478 | $forbiddenForStandardAccounts = ['debit_negative_balances', 'decline_charge_on', 'payout_schedule', 'payout_statement_descriptor']; |
|
| 479 | foreach ($forbiddenForStandardAccounts as $field) { |
|
| 480 | $rootNode->validate() |
|
| 481 | ->ifTrue(function ($v) use ($field) { |
|
| 482 | return isset($v['type']) && Account::TYPE_STANDARD === $v['type'] && isset($v[$field]); |
|
| 483 | }) |
|
| 484 | ->thenInvalid("You cannot set \"$field\" for standard accounts.") |
|
| 485 | ->end(); |
|
| 486 | } |
|
| 487 | ||
| 488 | $rootNode |
|
| 489 | ->validate() |
|
| @@ 117-124 (lines=8) @@ | ||
| 114 | ; |
|
| 115 | ||
| 116 | $goodOnlyFields = ['caption', 'deactivate_on', 'description', 'package_dimensions', 'shippable', 'url']; |
|
| 117 | foreach ($goodOnlyFields as $field) { |
|
| 118 | $rootNode->validate() |
|
| 119 | ->ifTrue(function ($v) use ($field) { |
|
| 120 | return isset($v['type']) && Product::TYPE_GOOD !== $v['type'] && isset($v[$field]); |
|
| 121 | }) |
|
| 122 | ->thenInvalid("You can only set \"$field\" for \"good\" products.") |
|
| 123 | ->end(); |
|
| 124 | } |
|
| 125 | ||
| 126 | return $treeBuilder; |
|
| 127 | } |
|