Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. def value=(val)
  2. if val
  3. if [:char].include?(@type) && val.length >= args[:limit] && val == 'true'
  4. val = 'Y'
  5. elsif [:char].include?(@type) && val.length >= args[:limit] && val == 'false'
  6. val = 'N'
  7. elsif [:bit].include?(@type) && val.length >= args[:limit] && val == 'true'
  8. val = 1
  9. elsif [:bit].include?(@type) && val.length >= args[:limit] && val == 'false'
  10. val = 0
  11. elsif [:varchar, :char, :nvarchar].include?(@type) && @args[:limit]
  12. unless val.length <= args[:limit]
  13. msg = "The length of #{@name} exceeds the max limit #{@args[:limit]}"
  14. raise Programmability::BadRequestError.new(nil, msg)
  15. end
  16. elsif [:numeric].include?(@type) && @args[:precision] && @args[:scale]
  17. valid_numeric?(val, @args[:precision], @args[:scale])
  18. elsif [:datetime].include?(@type)
  19. valid_date?(val)
  20. end
  21. end
  22. @value = val
  23. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement