-
-
Save T-800/51d507a09f87e47db235cbbd7f6dda7a to your computer and use it in GitHub Desktop.
dry-validation conditional validation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Fund::CreateCallForm < BaseForm | |
| property :type | |
| property :fund | |
| validation do | |
| required(:type) { filled? & included_in?(TRANSACTION_TYPES['Fund::Call']) } | |
| end | |
| validation if: -> (results) { rebalance? } do | |
| required(:fund).filled | |
| end | |
| def rebalance? | |
| self.type == 'rebalance' | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment