Class DataFormDateOptionsAttribute
Provides attribute-level configuration of minimum date, maximum date, and date format for date editors within the Syncfusion.Blazor.DataForm.
Inheritance
Namespace: Syncfusion.Blazor.DataForm
Assembly: Syncfusion.Blazor.dll
Syntax
public sealed class DataFormDateOptionsAttribute : ValidationAttribute
Remarks
This attribute customizes allowed date ranges and their format for a specific property in a DataForm model class. Set MinimumDate and MaximumDate as string representations, and optionally define a format string according to .NET date formatting patterns.
Examples
public class MeetingModel
{
[DataFormDateOptions(MinimumDate = "01/01/2024", MaximumDate = "31/12/2024", Format = "dd/MM/yyyy")]
public DateTime? MeetingDate { get; set; }
}
Constructors
DataFormDateOptionsAttribute()
Initializes a new instance of the DataFormDateOptionsAttribute class with default values.
Declaration
public DataFormDateOptionsAttribute()
Remarks
Defaults: MinimumDate and MaximumDate are set to empty strings (no limitation). Format is set to the active culture's short date pattern.
Properties
Format
Gets or sets the date format string used to parse MinimumDate and MaximumDate values.
Declaration
public string Format { get; set; }
Property Value
Type | Description |
---|---|
System.String | A System.String representing the .NET date format pattern. The default value is based on the current culture's ShortDatePattern. |
Remarks
Use standard .NET date format strings (e.g., "yyyy-MM-dd"
, "dd/MM/yyyy"
). The format should correspond to how MinimumDate and MaximumDate are specified. If omitted, the system default short date is used.
Usage example:
[DataFormDateOptions(MaximumDate = "22/02/2024", MinimumDate = "22/01/2024", Format = "dd/MM/yyyy")]
public DateTime? DateTimeValue { get; set; }
Examples
[DataFormDateOptions(Format = "MM/dd/yyyy")]
public DateTime? USFormatDate { get; set; }
MaximumDate
Gets or sets the maximum date, as a string, that is allowed for selection in a date editor field within the DataForm.
Declaration
public string MaximumDate { get; set; }
Property Value
Type | Description |
---|---|
System.String | A |
Remarks
Set to an empty string (string.Empty
) if you do not intend to restrict the upper bound. The format must match the Format property. The restriction applies only if both MaximumDate and Format are provided.
Usage example:
[DataFormDateOptions(MaximumDate = "22/02/2024", Format = "dd/MM/yyyy")]
public DateTime? DateTimeValue { get; set; }
Examples
[DataFormDateOptions(MaximumDate = "31/12/2024", Format = "dd/MM/yyyy")]
public DateTime? EndDate { get; set; }
MinimumDate
Gets or sets the minimum date, as a string, that is allowed for selection in a date editor field within the DataForm.
Declaration
public string MinimumDate { get; set; }
Property Value
Type | Description |
---|---|
System.String | A |
Remarks
Set to an empty string (string.Empty
) if you do not intend to limit the lower bound. The format must match the Format property. The restriction applies only if both MinimumDate and Format are provided.
Usage example:
[DataFormDateOptions(MinimumDate = "22/01/2024", Format = "dd/MM/yyyy")]
public DateTime? DateTimeValue { get; set; }
Examples
[DataFormDateOptions(MinimumDate = "01/01/2023", Format = "dd/MM/yyyy")]
public DateTime? Birthday { get; set; }
Methods
IsValid(Object)
Determines whether the specified value is a valid date within the configured minimum and maximum range.
Declaration
public override bool IsValid(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The value of the property being validated. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Remarks
If the value
is null, not a parseable date, or out of the allowed range according to MinimumDate and MaximumDate, this returns false
.
Examples
[DataFormDateOptions(MinimumDate = "01/01/2023", MaximumDate = "31/12/2023", Format = "dd/MM/yyyy")]
public DateTime? ScheduleDate { get; set; }