ModelValidatorsExtensionsIsNameValid Method

Check whether the name property has been properly filled in. A name should satisfy these requirements: No digits (0-9): Names should not contain any numerical characters. No forbidden special characters: Characters like @, !, ?, #, ,, $, _, &, (, ) are not allowed. Only valid punctuation is allowed: Apostrophes (') and hyphens (-) are permitted but must be used correctly (e.g., no double hyphens like Anne--Marie and no trailing hyphens like Carlos-Name-). No consecutive spaces: A name should not have multiple spaces in a row (e.g., Li Wei). No leading or trailing spaces: Names should not start or end with spaces (e.g., " Sarah" or "Jack "). Apostrophes should be used correctly: They should not have spaces before them (e.g., "O' Connor" is incorrect; "O'Connor" is correct). Hyphens should be used correctly: They should only be used to separate parts of a name, not appear at the start, end, or in double form.

Definition

Namespace: MobileTrack.Common.Extensions
Assembly: MobileTrack.Common (in MobileTrack.Common.dll) Version: 0.7+ce90b2cf6b782b8d7b7fd47b3c546987c652c00f
public static bool IsNameValid(
	this string name,
	string propertyName,
	out ValidationModel validationModel
)

Parameters

name  String
The name string
propertyName  String
Name of the property
validationModel  ValidationModel
Validation model based on the result of the method

Return Value

Boolean
if name is valid

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type String. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

See Also