如何验证url以使用Regexp(ruby)

时间:2017-09-21 09:03:44

标签: ruby regex validation

我希望验证image_url属性始终以

开头
https://res.yakari.com/myapp/

以下是使用Regexp进行的当前验证

validates_format_of :image_url,
  :with => /\Ahttps:\/\/res.yakari.com\/myapp\/\S*\z/i,
  :message => "There's something wrong (doesn't begin with https://res.yakari.com/myapp, wrong path, white space inside string...)"

但是它不起作用,我测试了它,它甚至拒绝正确的字符串(以https://res.yakari.com/myapp/开头的那些字符串)

怎么做?

0 个答案:

没有答案