| | | 1 | | using System.Text.RegularExpressions; |
| | | 2 | | using ValidateLib.ErrorsAndWarnings.Errors; |
| | | 3 | | using ValidateLib.Metadata.Descriptors; |
| | | 4 | | |
| | | 5 | | namespace ValidateLib.TabularData.Datatypes.StringDatatypes |
| | | 6 | | { |
| | | 7 | | public class NormalizedStringDT : StringDT |
| | | 8 | | { |
| | 1 | 9 | | public NormalizedStringDT() { } |
| | 1 | 10 | | public NormalizedStringDT(string stringValue) : base(stringValue) |
| | | 11 | | { |
| | 1 | 12 | | CheckLexicalSpace(stringValue); |
| | 1 | 13 | | } |
| | | 14 | | |
| | 1 | 15 | | public NormalizedStringDT(string stringValue, FormatDescriptor format) : base(stringValue, format) |
| | | 16 | | { |
| | 1 | 17 | | CheckLexicalSpace(stringValue); |
| | 1 | 18 | | } |
| | | 19 | | |
| | | 20 | | public static void CheckLexicalSpace(string stringValue) |
| | | 21 | | { |
| | | 22 | | |
| | 1 | 23 | | string disallowedPattern = "[\x0A\x0D\x09]"; |
| | | 24 | | |
| | | 25 | | // Check if the input string matches the disallowed pattern |
| | 1 | 26 | | if (Regex.IsMatch(stringValue, disallowedPattern)) |
| | 1 | 27 | | ErrorFactory.ThrowDatatypeValidationError(stringValue); |
| | 1 | 28 | | } |
| | | 29 | | } |
| | | 30 | | } |