Пример #1
0
 private bool FieldNeedsValidation <T>(CustomMandatoryField field, Func <T, bool> predicate, T t)
 {
     if (predicate != null)
     {
         return(predicate(t) && EidssSiteContext.Instance.CustomMandatoryFields.Contains(field));
     }
     return(EidssSiteContext.Instance.CustomMandatoryFields.Contains(field));
 }
Пример #2
0
 public void Validate <T>(T t, DateTime f, CustomMandatoryField field, Func <T, bool> predicate = null)
     where T : IObject
 {
     if (FieldNeedsValidation(field, predicate, t))
     {
         if (f == DateTime.MinValue)
         {
             throw new ValidationModelException(m_MsgId, m_FldName, m_PrpName, m_Pars, typeof(RequiredValidator), m_ValidationType, t);
         }
     }
 }
Пример #3
0
        public void Validate <T, F>(T t, Nullable <F> f, CustomMandatoryField field, Func <T, bool> predicate = null)
            where F : struct
            where T : IObject
        {
            if (FieldNeedsValidation(field, predicate, t))
            {
                if (f == null)
                {
                    throw new ValidationModelException(m_MsgId, m_FldName, m_PrpName, m_Pars, typeof(RequiredValidator), m_ValidationType, t);
                }

                if (!f.HasValue)
                {
                    throw new ValidationModelException(m_MsgId, m_FldName, m_PrpName, m_Pars, typeof(RequiredValidator), m_ValidationType, t);
                }
            }
        }
Пример #4
0
        public void Validate <T, F>(T t, F f, CustomMandatoryField field, Func <T, bool> predicate = null)
            where F : class
            where T : IObject
        {
            if (FieldNeedsValidation(field, predicate, t))
            {
                if (f == null)
                {
                    throw new ValidationModelException(m_MsgId, m_FldName, m_PrpName, m_Pars, typeof(RequiredValidator), m_ValidationType, t);
                }

                var s = f as string;
                if (s != null)
                {
                    if (s.Length == 0)
                    {
                        throw new ValidationModelException(m_MsgId, m_FldName, m_PrpName, m_Pars, typeof(RequiredValidator), m_ValidationType, t);
                    }
                }
            }
        }