// ***********************************************************************
// Assembly : Construction
// Author : zjx
// Created : 07-28-2020
//
// Last Modified By : zjx
// Last Modified On : 09-01-2020
// ***********************************************************************
//
// Copyright (c) jindongfang. All rights reserved.
//
//
// ***********************************************************************
namespace WellWorkDataUI
{
using System;
using System.Text.RegularExpressions;
///
/// Class Validation.
///
public static class Validation
{
private static readonly Regex RegexNumber = new Regex(@"^[+-]?\d*[.]?\d*$", RegexOptions.Compiled);
///
/// Determines whether [is date time] [the specified input].
///
/// The input.
/// true if [is date time] [the specified input]; otherwise, false.
public static bool IsDateTime(string input)
{
return DateTime.TryParse(input, out DateTime _);
}
///
/// Determines whether the specified input is decimal.
///
/// The input.
/// true if the specified input is decimal; otherwise, false.
public static bool IsDecimal(string input)
{
return IsNumber(input) && input.Contains(".");
}
///
/// Determines whether [is less than] [the specified input].
///
/// The input.
/// The length.
/// true if [is less than] [the specified input]; otherwise, false.
public static bool IsLessThan(string input, int length)
{
return input.Length < length;
}
///
/// Determines whether [is not empty] [the specified input].
///
/// The input.
/// true if [is not empty] [the specified input]; otherwise, false.
public static bool IsNotEmpty(string input)
{
return !string.IsNullOrWhiteSpace(input);
}
///
/// Determines whether the specified input is number.
///
/// The input.
/// true if the specified input is number; otherwise, false.
public static bool IsNumber(string input)
{
return RegexNumber.IsMatch(input);
}
}
}