Commit ff7fe3f4 authored by Zac Wood's avatar Zac Wood

Fixed broken validators

parent f057e725
......@@ -6,7 +6,7 @@ class CourseSectionsController < ApplicationController
end
api :GET, '/courses_sections', 'Get a list of course sections'
param :course_id, Fixnum, desc: "Only get the course sections belonging to the course with this ID"
param :course_id, Integer, desc: "Only get the course sections belonging to the course with this ID"
param :crn, String, desc: "Get the course section with this CRN"
def index
@sections = CourseSection.all
......
......@@ -6,7 +6,7 @@ class CoursesController < ApplicationController
api :GET, '/courses', "Get a list of courses."
param :subject, String, desc: 'Course subject, e.g. "CS" or "ACCT"'
param :course_number, :number, desc: 'Course number, e.g. "112"'
param :course_number, Integer, desc: 'Course number, e.g. "112"'
def index
@courses = Course.all
......@@ -17,7 +17,6 @@ class CoursesController < ApplicationController
render json: @courses
end
# Renders JSON of details of a singluar course, such as its sections
api :GET, '/courses/:id', "Get a list of all course sections for the course with the given id."
param :id, :number, desc: 'Course ID', required: true
def show
......
......@@ -9,7 +9,7 @@ class SchedulesController < ApplicationController
# Render an iCal file containing the schedules of all the
# course sections with the given CRNs.
api :GET, '/schedules', 'Generate an iCal file with events for the given CRNs'
param :crns, Array, of: String, desc: 'Array of CRNs to include as events in the calendar', required: true
param :crns, String, desc: 'Comma separated list of CRNs to include as events in the calendar', required: true
def index
crns = params["crns"].split ','
@schedule = Schedule.new crns
......
class IntegerValidator < Apipie::Validator::BaseValidator
def initialize(param_description, argument)
super(param_description)
@type = argument
end
def validate(value)
return false if value.nil?
!!(value.to_s =~ /^[-+]?[0-9]+$/)
end
def self.build(param_description, argument, options, block)
if argument == Integer
self.new(param_description, argument)
end
end
def description
"Must be #{@type}."
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment