Advertisement
Guest User

Untitled

a guest
Sep 15th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.48 KB | None | 0 0
  1. # using dry-validation (0.9.5)
  2.  
  3. test_1 = Dry::Validation.Schema { required(:param_1) { format?(/^[A-Z]+$/) }  }
  4. test_1.call({ param_1: 'SOMETHINGLONGERA'}).messages
  5. => {}    
  6.  
  7.  
  8.  
  9.  
  10. test_2 = Dry::Validation.Schema { required(:param_1) { max_size?(15) & format?(/^[A-Z]+$/) } }
  11. test_2.call({ param_1: 'SOMETHINGLONGERA'}).messages
  12.  
  13. Got :
  14.  => {:param_1=>["size cannot be greater than 15", "is in invalid format"]}
  15.  
  16. Expected :
  17.  => {:param_1=>["size cannot be greater than 15"]}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement