mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
1020 B
29 lines
1020 B
// ==========================================================================
|
|
// Extensions.cs
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex Group
|
|
// All rights reserved.
|
|
// ==========================================================================
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace Squidex.Infrastructure
|
|
{
|
|
public static class Extensions
|
|
{
|
|
private static readonly Regex SlugRegex = new Regex("^[a-z0-9]+(\\-[a-z0-9]+)*$", RegexOptions.Compiled);
|
|
|
|
public static bool IsSlug(this string value)
|
|
{
|
|
return value != null && SlugRegex.IsMatch(value);
|
|
}
|
|
|
|
public static bool IsBetween<TValue>(this TValue value, TValue low, TValue high) where TValue : IComparable
|
|
{
|
|
return Comparer<TValue>.Default.Compare(low, value) <= 0 && Comparer<TValue>.Default.Compare(high, value) >= 0;
|
|
}
|
|
}
|
|
}
|
|
|