Skip to content

Instantly share code, notes, and snippets.

@T-800
Forked from igor-alexandrov/form.rb
Created March 20, 2018 09:03
Show Gist options
  • Select an option

  • Save T-800/51d507a09f87e47db235cbbd7f6dda7a to your computer and use it in GitHub Desktop.

Select an option

Save T-800/51d507a09f87e47db235cbbd7f6dda7a to your computer and use it in GitHub Desktop.

Revisions

  1. @igor-alexandrov igor-alexandrov revised this gist Mar 29, 2017. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions form.rb
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,10 @@ 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
  2. @igor-alexandrov igor-alexandrov revised this gist Mar 29, 2017. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion form.rb
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,12 @@
    class Fund::CreateCallForm < BaseForm
    property :type
    property :fund

    validation if: -> (results) { rebalance? } do
    required(:fund).filled
    end

    def rebalance?
    self.type == 'rebalance'
    end
    end
    end
  3. @igor-alexandrov igor-alexandrov renamed this gist Mar 29, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. @igor-alexandrov igor-alexandrov created this gist Mar 29, 2017.
    7 changes: 7 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    validation if: -> (results) { rebalance? } do
    required(:fund).filled
    end

    def rebalance?
    self.type == 'rebalance'
    end