예제 #1
0
 /// <summary>
 /// Validates a value to the specified format.
 /// </summary>
 /// <param name="value">The value to validate.</param>
 /// <returns>True if the value is valid, otherwise false.</returns>
 public bool Validate(string value)
 {
     if (ValidationRegex == null)
     {
         return(ValidationFunction == null || ValidationFunction(value));
     }
     return(ValidationRegex.IsMatch(value));
 }
 public void ValidateText(string text)
 {
     if (ValidationRegex != null)
     {
         bool match = ValidationRegex.IsMatch(text);
         ShowCautionImage = !match;
     }
 }
예제 #3
0
        /// <inheritdoc />
        protected override StringValueNode ParseValue(string runtimeValue)
        {
            if (!ValidationRegex.IsMatch(runtimeValue))
            {
                throw ThrowHelper.HslaType_ParseValue_IsInvalid(this);
            }

            return(base.ParseValue(runtimeValue));
        }
예제 #4
0
        /// <inheritdoc />
        protected override string ParseLiteral(StringValueNode valueSyntax)
        {
            if (!ValidationRegex.IsMatch(valueSyntax.Value))
            {
                throw ThrowHelper.HslaType_ParseLiteral_IsInvalid(this);
            }

            return(base.ParseLiteral(valueSyntax));
        }
예제 #5
0
 /// <summary>
 /// Validates a value to the specified format.
 /// </summary>
 /// <param name="value">The value to validate.</param>
 /// <returns>True if the value is valid, otherwise false.</returns>
 public bool Validate(JsonValue value)
 {
     return(ValidationRegex == null || value.Type != JsonValueType.String
                         ? ValidationFunction == null || ValidationFunction(value)
                         : ValidationRegex.IsMatch(value.String));
 }