Skip to content

Commit 52a3308

Browse files
committed
remove support for array validations
1 parent c99bf12 commit 52a3308

File tree

4 files changed

+10
-37
lines changed

4 files changed

+10
-37
lines changed

lib/bashly/models/base.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,6 @@ def help
4747
options['help'] ||= ''
4848
end
4949

50-
def validations
51-
return [] unless options['validate']
52-
if options['validate'].is_a? String
53-
[options['validate']]
54-
else
55-
options['validate']
56-
end
57-
end
58-
5950
def method_missing(method_name, *arguments, &block)
6051
key = method_name.to_s
6152
respond_to?(method_name) ? options[key] : super
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
% validations.each do |validation_function|
2-
if [[ -n $(validate_<%= validation_function %> "$1") ]]; then
3-
printf "<%= strings[:validation_error] %>\n" "<%= name.upcase %>" "$(validate_<%= validation_function %> "$1")"
1+
# :argument.validations
2+
% if validate
3+
if [[ -n $(validate_<%= validate %> "$1") ]]; then
4+
printf "<%= strings[:validation_error] %>\n" "<%= name.upcase %>" "$(validate_<%= validate %> "$1")"
45
exit 1
56
fi
7+
68
% end

lib/bashly/views/flag/validations.erb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
% validations.each do |validation_function|
2-
if [[ -n $(validate_<%= validation_function %> "$2") ]]; then
3-
printf "<%= strings[:validation_error] %>\n" "<%= usage_string %>" "$(validate_<%= validation_function %> "$2")"
1+
# :flag.validations
2+
% if validate
3+
if [[ -n $(validate_<%= validate %> "$2") ]]; then
4+
printf "<%= strings[:validation_error] %>\n" "<%= usage_string %>" "$(validate_<%= validate %> "$2")"
45
exit 1
56
fi
7+
68
% end

spec/bashly/models/base_spec.rb

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,4 @@
3939
end
4040
end
4141
end
42-
43-
describe '#validations' do
44-
context "when validate is empty" do
45-
it "returns an empty array" do
46-
expect(subject.validations).to eq []
47-
end
48-
end
49-
50-
context "when validate is a String" do
51-
let(:options) { {"validate" => "integer"} }
52-
it "returns an array of validation names" do
53-
expect(subject.validations).to eq ["integer"]
54-
end
55-
end
56-
57-
context "when validate is an array" do
58-
let(:options) { {"validate" => ["black", "white"]} }
59-
it "returns an array of validation names" do
60-
expect(subject.validations).to eq ["black", "white"]
61-
end
62-
end
63-
end
6442
end

0 commit comments

Comments
 (0)