< Summary

Information
Class: ValidateLib.Metadata.Descriptors.DatatypeDescriptor
Assembly: validatelib.dll
File(s): C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\Descriptors\DatatypeDescriptor.cs
Line coverage
97%
Covered lines: 35
Uncovered lines: 1
Coverable lines: 36
Total lines: 94
Line coverage: 97.2%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\Descriptors\DatatypeDescriptor.cs

#LineLine coverage
 1using Newtonsoft.Json.Linq;
 2using ValidateLib.ErrorsAndWarnings.Warnings;
 3using ValidateLib.Metadata.Descriptors.Interfaces;
 4using ValidateLib.Metadata.Parsers;
 5using ValidateLib.Metadata.Properties.AtomicProperties;
 6using ValidateLib.Metadata.PropertyParsers;
 7using ValidateLib.Metadata.PropertyParsers.DataType;
 8
 9namespace ValidateLib.Metadata.Descriptors
 10{
 11    public class DatatypeDescriptor : Descriptor, INormalize, Interfaces.IParsable<DatatypeDescriptor>
 12    {
 113        public AtomicPropertyString? _base { get; set; } = new AtomicPropertyString("string") { IsDefault = true };
 114        public FormatDescriptor? format { get; set; }
 115        public AtomicPropertyInteger? length { get; set; }
 116        public AtomicPropertyInteger? minLength { get; set; }
 117        public AtomicPropertyInteger? maxLength { get; set; }
 118        public AtomicPropertyString? minimum { get; set; }
 119        public AtomicPropertyString? maximum { get; set; }
 120        public AtomicPropertyString? minInclusive { get; set; }
 121        public AtomicPropertyString? maxInclusive { get; set; }
 122        public AtomicPropertyString? minExclusive { get; set; }
 123        public AtomicPropertyString? maxExclusive { get; set; }
 24
 125        public bool IsBuiltIn = true;
 26        public static List<Warning> Normalize(JToken token, Context context, JProperty? property = null)
 27        {
 128            List<Warning> errors = new List<Warning>();
 129            if (token.Type == JTokenType.String)
 130                token.Replace(new JObject(new JProperty("base", token.ToString())));
 131            else if (token.Type == JTokenType.Object)
 132                foreach (JProperty jproperty in token) errors.AddRange(NormalizeProperty(jproperty, context));
 133            return errors;
 34
 35
 36        }
 37        new public static List<Warning> NormalizeProperty(JProperty property, Context context)
 38        {
 139            List<Warning> errors = new List<Warning>();
 140            switch (property.Name)
 41            {
 42                case "base":
 43                case "length":
 44                case "minlength":
 45                case "maxLength":
 46                case "minimum":
 47                case "maximum":
 48                case "minInclusive":
 49                case "maxInclusive":
 50                case "minExclusive":
 51                case "maxExclusive":
 52                case "format":
 153                    return errors;
 54                default:
 155                    return Descriptor.NormalizeProperty(property, context);
 56
 57            }
 58        }
 59
 60        new public IPropertyParserBase? GetPropertyParser(JProperty property, List<Warning> warnings)
 61        {
 162            switch (property.Name)
 63            {
 64                case "base":
 165                    return new BasePropertyParser(warnings, this);
 66                case "format":
 167                    return new FormatPropertyParser(warnings, this);
 68                case "length":
 169                    return new LengthPropertyParser(warnings, this);
 70                case "minLength":
 171                    return new MinLengthPropertyParser(warnings, this);
 72                case "maxLength":
 173                    return new MaxLengthPropertyParser(warnings, this);
 74                case "minimum":
 175                    return new MinimumPropertyParser(warnings, this);
 76                case "maximum":
 177                    return new MaximumPropertyParser(warnings, this);
 78                case "minInclusive":
 179                    return new MinInclusivePropertyParser(warnings, this);
 80                case "maxInclusive":
 181                    return new MaxInclusivePropertyParser(warnings, this);
 82                case "minExclusive":
 183                    return new MinExclusivePropertyParser(warnings, this);
 84                case "maxExclusive":
 185                    return new MaxExclusivePropertyParser(warnings, this);
 86                default:
 187                    return ((Descriptor)this).GetPropertyParser(property, warnings);
 88            }
 89        }
 90
 091        public static IParser<DatatypeDescriptor> GetParser(List<Warning> warnings, DatatypeDescriptor? descriptor = nul
 92
 93    }
 94}

Methods/Properties

_base()
_base(ValidateLib.Metadata.Properties.AtomicProperties.AtomicPropertyString)
DatatypeDescriptor()
format()
format(ValidateLib.Metadata.Descriptors.FormatDescriptor)
length()
length(ValidateLib.Metadata.Properties.AtomicProperties.AtomicPropertyInteger)
minLength()
minLength(ValidateLib.Metadata.Properties.AtomicProperties.AtomicPropertyInteger)
maxLength()
maxLength(ValidateLib.Metadata.Properties.AtomicProperties.AtomicPropertyInteger)
minimum()
minimum(ValidateLib.Metadata.Properties.AtomicProperties.AtomicPropertyString)
maximum()
maximum(ValidateLib.Metadata.Properties.AtomicProperties.AtomicPropertyString)
minInclusive()
minInclusive(ValidateLib.Metadata.Properties.AtomicProperties.AtomicPropertyString)
maxInclusive()
maxInclusive(ValidateLib.Metadata.Properties.AtomicProperties.AtomicPropertyString)
minExclusive()
minExclusive(ValidateLib.Metadata.Properties.AtomicProperties.AtomicPropertyString)
maxExclusive()
maxExclusive(ValidateLib.Metadata.Properties.AtomicProperties.AtomicPropertyString)
Normalize(Newtonsoft.Json.Linq.JToken, ValidateLib.Metadata.Descriptors.Context, Newtonsoft.Json.Linq.JProperty)
NormalizeProperty(Newtonsoft.Json.Linq.JProperty, ValidateLib.Metadata.Descriptors.Context)
GetPropertyParser(Newtonsoft.Json.Linq.JProperty, System.Collections.Generic.List<ValidateLib.ErrorsAndWarnings.Warnings.Warning>)
GetParser(System.Collections.Generic.List<ValidateLib.ErrorsAndWarnings.Warnings.Warning>, ValidateLib.Metadata.Descriptors.DatatypeDescriptor)