Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8696713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:20:21+00:00 2026-06-13T01:20:21+00:00

I have a model like this with a couple of fields such as name,

  • 0

I have a model like this with a couple of fields such as name, email and phone.
All of these are set with the [Required] attribute.

What I would like to do is override the RequiredAttribute and only require the property if the current visitor of the website is not an administrator. So basically an administrator can type what they like or leave a field empty where as normal users cannot.

Can anyone point me in the right direction or advise on the best way to acheive this ?

To find out if a visitor is admin I use:

var permissionId = Helpers.ConvertToInt(Services.UserService.GetCurrentPermissionId().ToString());

If this is 0 or 1 then the visitor is not an administrator so the field should be required.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:20:22+00:00Added an answer on June 13, 2026 at 1:20 am

    I would suggest looking into using FluentValidation which will allow you to specify much more complicated rules then the built in data annotations allow without having to build custom attributes.

    You could then solve this by using syntax similar to this:

    RuleFor(obj => obj.Email).NotEmpty().Unless(obj => Helpers.ConvertToInt(Services.UserService.GetCurrentPermissionId()) > 1)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a couple of Django models set up like this: class Group(models.model): name
I have a model like this: class Users(db.Model): email = db.EmailProperty(required=True, indexed=True) user_name =
I have a simple model like this one: class Artist(models.Model): surname = models.CharField(max_length=200) name
I have a model like this class Task(models.Model): name = models.CharField(max_length=100) ... class TaskForm(forms.ModelForm):
I have model like this: scope :search_posts, lambda { |query| mega_posts.where( title LIKE ?
i've a problem with my tabularinline field. I have model like this class Product(models.Model):
I have entity model like this (using EclipseLink and JPA 2.0): @Entity class A
So I have a model like this: class MyClass { public $customer = null;
I'm using MVC3 and I have a model like this: public class Foo {
I have a simple model like this: class User < ActiveRecord::Base serialize :preferences end

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.