HighLine:Examples:Validation
まんま
require "highline/import" p ask("Age? ", Integer) { |q| q.in = 0..105 } p ask("Name? (last, first) ") { |q| q.validate = /\A\w+, ?\w+\Z/ }
で、
Age? -1 Your answer isn't within the expected range (included in 0..105). ? 106 Your answer isn't within the expected range (included in 0..105). ? 105 105 Name? (last, first) L R Your answer isn't valid (must match /\A\w+, ?\w+\Z/). ? L, R "L, R"