mirror of
https://github.com/zhigang1992/rmq.git
synced 2026-04-29 05:05:36 +08:00
added selection rule test for white_list 🌟
This commit is contained in:
@@ -105,10 +105,11 @@ module RubyMotionQuery
|
||||
end
|
||||
|
||||
def valid?(data, options={})
|
||||
# shortcircuit for universal validation options
|
||||
return true if universal_validation_checks(data, options)
|
||||
|
||||
@options = options.merge(@options)
|
||||
|
||||
# shortcircuit for universal validation parameters
|
||||
return true if universal_validation_checks(data, @options)
|
||||
|
||||
@valid_status = @rule.call(data, @options)
|
||||
end
|
||||
|
||||
|
||||
@@ -147,8 +147,15 @@ describe 'validation' do
|
||||
|
||||
it 'accepts a whitelist of validation overrides' do
|
||||
# Utility Level
|
||||
@rmq.validation.valid?('http://localhost', :url).should == false
|
||||
@rmq.validation.valid?('http://localhost', :url, white_list: ['http://localhost']).should == true
|
||||
@rmq.validation.valid?('http://localhost:3000', :url).should == false
|
||||
@rmq.validation.valid?('http://localhost:3000', :url, white_list: ['http://localhost:8080', 'http://localhost:3000']).should == true
|
||||
|
||||
# Validation Selection level
|
||||
vc = UIViewController.new
|
||||
vc.rmq.append(UITextField).validates(:number).data('N/A').tag(:one)
|
||||
vc.rmq(:one).valid?.should == false
|
||||
vc.rmq.append(UITextField).validates(:number, white_list: ['N/A']).data('N/A').tag(:two)
|
||||
vc.rmq(:two).valid?.should == true
|
||||
end
|
||||
|
||||
it 'checks validations based on selections' do
|
||||
|
||||
Reference in New Issue
Block a user