Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def value=(val)
- if val
- if [:char].include?(@type) && val.length >= args[:limit] && val == 'true'
- val = 'Y'
- elsif [:char].include?(@type) && val.length >= args[:limit] && val == 'false'
- val = 'N'
- elsif [:bit].include?(@type) && val.length >= args[:limit] && val == 'true'
- val = 1
- elsif [:bit].include?(@type) && val.length >= args[:limit] && val == 'false'
- val = 0
- elsif [:varchar, :char, :nvarchar].include?(@type) && @args[:limit]
- unless val.length <= args[:limit]
- msg = "The length of #{@name} exceeds the max limit #{@args[:limit]}"
- raise Programmability::BadRequestError.new(nil, msg)
- end
- elsif [:numeric].include?(@type) && @args[:precision] && @args[:scale]
- valid_numeric?(val, @args[:precision], @args[:scale])
- elsif [:datetime].include?(@type)
- valid_date?(val)
- end
- end
- @value = val
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement