public IEnumerable <IValidator> CreateFieldValidators(ValidatorContext context, IField field, ValidatorFactory factory)
 {
     if (field is IField <UIFieldProperties> )
     {
         yield return(NoValueValidator.Instance);
     }
 }
示例#2
0
        public static IEnumerable <IValidator> CreateValidators(ValidatorContext context, IField field, ValidatorFactory createFieldValidator)
        {
            Guard.NotNull(context, nameof(context));
            Guard.NotNull(field, nameof(field));

            var visitor = new DefaultFieldValueValidatorsFactory(context, createFieldValidator);

            return(field.Accept(visitor));
        }
        private static bool IsRequired(FieldProperties properties, ValidatorContext context)
        {
            var isRequired = properties.IsRequired;

            if (context.Action == ValidationAction.Publish)
            {
                isRequired = isRequired || properties.IsRequiredOnPublish;
            }

            return(isRequired);
        }
 public IEnumerable <IValidator> CreateValueValidators(ValidatorContext context, IField field, ValidatorFactory factory)
 {
     return(DefaultFieldValueValidatorsFactory.CreateValidators(context, field, factory));
 }
        public static IEnumerable <IValidator> CreateValidators(ValidatorContext context, IField field, ValidatorFactory createFieldValidator)
        {
            var args = new Args(context, createFieldValidator);

            return(field.Accept(Instance, args));
        }
            public Args(ValidatorContext context, ValidatorFactory factory)
            {
                Context = context;

                Factory = factory;
            }
示例#7
0
 public sealed record Args(ValidatorContext Context, ValidatorFactory Factory);
示例#8
0
 private DefaultFieldValueValidatorsFactory(ValidatorContext context, ValidatorFactory createFieldValidator)
 {
     this.context = context;
     this.createFieldValidator = createFieldValidator;
 }