DateConstraints
This class defines a set of constraints for validating date values by specifying upper and lower bounds. It supports inclusive and exclusive comparisons, as well as dynamic constraints relative to the current date.
Attributes
| Attribute | Type | Description |
|---|---|---|
| le | Date | Specifies the maximum inclusive date allowed for the field value. |
| lt | Date | Specifies the exclusive upper bound date that the field value must be strictly less than. |
| ge | Date | Specifies the minimum inclusive date allowed for the field value. |
| gt | Date | Specifies the exclusive lower bound date that the field value must be strictly greater than. |
| today | [NowConstraint](../datetime/nowconstraint.md?sid=validators_datetime_nowconstraint) | Defines dynamic constraints relative to the current system date at the time of validation. |
Constructor
Signature
def DateConstraints(
le: Option< Date > = null,
lt: Option< Date > = null,
ge: Option< Date > = null,
gt: Option< Date > = null,
today: Option< NowConstraint > = null
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| le | Option< Date > = null | Less than or equal to constraint |
| lt | Option< Date > = null | Less than constraint |
| ge | Option< Date > = null | Greater than or equal to constraint |
| gt | Option< Date > = null | Greater than constraint |
| today | Option< NowConstraint > = null | Constraint relative to the current date |
Methods
le()
def le(
le: Date
) - > [DateConstraints](dateconstraints.md?sid=validators_date_dateconstraints)
Sets the inclusive upper bound for the date value. Use this to ensure a date is on or before a specific calendar day.
Parameters
| Name | Type | Description |
|---|---|---|
| le | Date | The maximum allowable date, inclusive of the specified day. |
Returns
| Type | Description |
|---|---|
[DateConstraints](dateconstraints.md?sid=validators_date_dateconstraints) | The updated DateConstraints instance with the less-than-or-equal-to constraint applied. |
lt()
def lt(
lt: Date
) - > [DateConstraints](dateconstraints.md?sid=validators_date_dateconstraints)
Sets the exclusive upper bound for the date value. Use this to ensure a date occurs strictly before a specific calendar day.
Parameters
| Name | Type | Description |
|---|---|---|
| lt | Date | The date that the value must be strictly earlier than. |
Returns
| Type | Description |
|---|---|
[DateConstraints](dateconstraints.md?sid=validators_date_dateconstraints) | The updated DateConstraints instance with the less-than constraint applied. |
ge()
def ge(
ge: Date
) - > [DateConstraints](dateconstraints.md?sid=validators_date_dateconstraints)
Sets the inclusive lower bound for the date value. Use this to ensure a date is on or after a specific calendar day.
Parameters
| Name | Type | Description |
|---|---|---|
| ge | Date | The minimum allowable date, inclusive of the specified day. |
Returns
| Type | Description |
|---|---|
[DateConstraints](dateconstraints.md?sid=validators_date_dateconstraints) | The updated DateConstraints instance with the greater-than-or-equal-to constraint applied. |
gt()
def gt(
gt: Date
) - > [DateConstraints](dateconstraints.md?sid=validators_date_dateconstraints)
Sets the exclusive lower bound for the date value. Use this to ensure a date occurs strictly after a specific calendar day.
Parameters
| Name | Type | Description |
|---|---|---|
| gt | Date | The date that the value must be strictly later than. |
Returns
| Type | Description |
|---|---|
[DateConstraints](dateconstraints.md?sid=validators_date_dateconstraints) | The updated DateConstraints instance with the greater-than constraint applied. |
today()
def today(
today: [NowConstraint](../datetime/nowconstraint.md?sid=validators_datetime_nowconstraint)
) - > [DateConstraints](dateconstraints.md?sid=validators_date_dateconstraints)
Applies a constraint relative to the current system date. Use this to validate dates against a rolling 'now' reference, such as requiring a date to be in the future.
Parameters
| Name | Type | Description |
|---|---|---|
| today | [NowConstraint](../datetime/nowconstraint.md?sid=validators_datetime_nowconstraint) | The relative time constraint configuration used to compare the value against the current date. |
Returns
| Type | Description |
|---|---|
[DateConstraints](dateconstraints.md?sid=validators_date_dateconstraints) | The updated DateConstraints instance with the relative 'now' constraint applied. |