| | 1 | | using Newtonsoft.Json.Linq; |
| | 2 | | using ValidateLib.ErrorsAndWarnings.Warnings; |
| | 3 | | using ValidateLib.Metadata.Descriptors; |
| | 4 | |
|
| | 5 | | namespace ValidateLib.Metadata.PropertyParsers.DataType |
| | 6 | | { |
| | 7 | | internal class FormatPropertyParser : PropertyParserBase<DatatypeDescriptor>, IPropertyParser<DatatypeDescriptor> |
| | 8 | | { |
| 1 | 9 | | public FormatPropertyParser(List<Warning> warnings, DatatypeDescriptor descriptor) : base(warnings, descriptor) |
| | 10 | | { |
| 1 | 11 | | } |
| | 12 | |
|
| | 13 | | public void ParseProperty(JProperty property) |
| | 14 | | { |
| 1 | 15 | | Descriptor.IsBuiltIn = false; |
| 1 | 16 | | bool wasObject = true; |
| 1 | 17 | | if (property.Value.Type == JTokenType.String) |
| | 18 | | { |
| 1 | 19 | | property.Value.Replace(new JObject(new JProperty("pattern", property.Value.ToString()))); |
| 1 | 20 | | wasObject = false; |
| | 21 | | } |
| | 22 | |
|
| 1 | 23 | | if (property.Value.Type != JTokenType.Object) |
| 0 | 24 | | Warnings.Add(WarningFactory.GetFormatPropertyWrongValueWarning(property.Value.ToString(), property.Value |
| | 25 | | else |
| | 26 | | { |
| 1 | 27 | | var formatParser = FormatDescriptor.GetParser(Warnings); |
| 1 | 28 | | var formatValue = formatParser.ParseJToken(property.Value, property.Name); |
| 1 | 29 | | Descriptor.format = formatValue; |
| 1 | 30 | | Descriptor.format.wasObject = wasObject; |
| | 31 | | } |
| | 32 | |
|
| 1 | 33 | | } |
| | 34 | | } |
| | 35 | | } |