-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add validation for username and fullname presence
- Loading branch information
1 parent
264d416
commit 7327527
Showing
3 changed files
with
12 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
--require spec_helper | ||
--format documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
class User < ApplicationRecord | ||
validates :username, presence: true, length: { minimum: 3, maximum: 10 } | ||
validates :fullname, presence: true, length: { minimum: 3, maximum: 20 } | ||
validates :username, presence: true, length: { minimum: 3, maximum: 10, | ||
too_long: 'Maximum allowed username is 10 characters.' | ||
too_short: 'Minimum allowed characters for username is 3' } | ||
validates :fullname, presence: true, length: { minimum: 6, maximum: 20, | ||
too_long: 'Maximum allowed fullname is 20 characters.' | ||
too_short: 'Minimum allowed characters for fullname is 6'} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe User, type: :model do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
it { should validate_presence_of(:username) } | ||
it { should validate_presence_of(:fullname) } | ||
|
||
|
||
|
||
end |