I am new to Sequel, using it for the first time.
I created a table:
# connect to an in-memory database
DB = Sequel.connect('postgres://ritesh:newpassword@localhost')
# create an items table
DB.create_table :items do
primary_key :id
String :first_name
String :last_name
String :email
String : zipcode
String : company_name
String : google
String :skype
String :phone
String :about
String :linkedin_profile_url
end
end
I want to put a regular expression constraint on the email
field:
VALID EMAIL REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
and similar validations I have to put on other columns when we use the model.
I found "Model Validations" for adding validation, but I am creating a table.
How do I put validation in the create_table
method? If I have to use this table for a model, how do I convert from the table to a model, or use Model?
I am using grape only, no Rails is used. It's a simple Rake app.