Пример #1
0
        public IResponse UpdateValidationCondition(ValidationCondition validationCondition)
        {
            GuardianOptions      options      = GuardianOptionsFactory.GetOptions();
            GuardianDataProvider dataProvider = options.GuardianDataProviderFactory();

            IValidationCondition createdValidation = dataProvider.UpdateValidationCondition(validationCondition);

            return(new JsonResponse(dataProvider.GetValidationCondition(createdValidation.ValidationConditionID)));
        }
Пример #2
0
 /**
  * Sets the data validation based upon a numerical condition
  */
 public virtual void setNumberValidation(double val, ValidationCondition c)
 {
     if (dataValidation && getDVParser().extendedCellsValidation())
     {
         //logger.warn("Cannot set data validation on " +
         //            CellReferenceHelper.getCellReference(writableCell) +
         //            " as it is part of a shared data validation");
         return;
     }
     clearValidationSettings();
     dvParser       = new DVParser(val, System.Double.NaN, c.getCondition());
     dropDown       = false;
     dataValidation = true;
 }
        /// <summary>
        ///   Checks value is type of <see cref="TType"/>
        /// </summary>
        public static IValidationCondition <object> IsType <TType>(
            this IValidationCondition <object> condition,
            Action <IValidationCondition <TType> >?typed = null)
        {
            if (condition.Value is TType)
            {
                var typedCondition = new ValidationCondition <TType>(
                    condition.ValidationContext,
                    condition.ValidationKey,
                    new Lazy <TType>(() => (TType)condition.Value));

                typed?.Invoke(typedCondition);

                condition.IsValid = typedCondition.IsValid ?? false;
            }
            else
            {
                condition.IsValid = true;
            }

            return(condition);
        }
Пример #4
0
        static void Main(string[] args)
        {
            var incomingParametersСorrectnessConditions = new List <ValidationCondition>()
            {
                new ValidationCondition(args.Length != 0, "Error: You entered no one parameter. Please, enter two parameters - number of records (int) and region (string)."),
                new ValidationCondition(args.Length == 2, "Error: You entered more or less than two parameters. Please, enter two parameters - number of records (int) and region (string)."),
            };

            if (ValidationCondition.AreValidated(incomingParametersСorrectnessConditions))
            {
                int    numberOfRecords = int.Parse(args[0]);
                string region          = args[1];
                var    regions         = new List <string>()
                {
                    "en_US", "ru_RU", "uk_UK"
                };
                var receivedDataСorrectnessConditions = new List <ValidationCondition>()
                {
                    new ValidationCondition(numberOfRecords > 0, "Error: You entered negative number of records. Number of records must be positive."),
                    new ValidationCondition(regions.Contains(region), "Error: Unidentified region. Please, enter region in format an example 'en_US'. Avialable regions:\n1. en_US\n2. ru_RU\n3. uk_UK"),
                };
                if (ValidationCondition.AreValidated(receivedDataСorrectnessConditions))
                {
                    SetCSVFormatting();
                    string locale = region.Split("_")[0];
                    GetFakePersons(numberOfRecords, locale);
                }
                else
                {
                    ValidationCondition.DisplayValidationErrors(receivedDataСorrectnessConditions);
                }
            }
            else
            {
                ValidationCondition.DisplayValidationErrors(incomingParametersСorrectnessConditions);
            }
        }
 public virtual void setNumberValidation(double val1, double val2,
     ValidationCondition c)
 {
     if (dataValidation && getDVParser().extendedCellsValidation())
         {
         //logger.warn("Cannot set data validation on " +
         //            CellReferenceHelper.getCellReference(writableCell) +
         //            " as it is part of a shared data validation");
         return;
         }
     clearValidationSettings();
     dvParser = new DVParser(val1,val2,c.getCondition());
     dropDown = false;
     dataValidation = true;
 }
 /**
  * Sets the numeric range against which to validate the data
  *
  * @param val1 the first number
  * @param val2 the second number
  * @param c the validation condition
  */
 public override void setNumberValidation(double val1,double val2,ValidationCondition c)
 {
     base.setNumberValidation(val1, val2, c);
 }
Пример #7
0
 /**
  * Sets the numeric range against which to validate the data
  *
  * @param val1 the first number
  * @param val2 the second number
  * @param c the validation condition
  */
 public override void setNumberValidation(double val1, double val2, ValidationCondition c)
 {
     base.setNumberValidation(val1, val2, c);
 }