Last active
July 19, 2019 03:13
-
-
Save igor-alexandrov/a129f51d44a207431410ed91d9780907 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