You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/forms/gitea/user_form.rb

25 lines
567 B

class Gitea::UserForm
EMAIL_REGEX = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/
include ActiveModel::Model
attr_accessor :username, :email, :password
validates :username, presence: true
validates :email, presence: true, format: { with: EMAIL_REGEX, multiline: true }
validates :password, presence: true
attr_reader :record
def persist
@record = id ? User.find(id) : User.new
if valid?
@record.attributes = attributes.except(:password_confirmation, :id)
@record.save!
true
else
false
end
end
end