Skip to main content

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

AttributeTypeDescription
leDateSpecifies the maximum inclusive date allowed for the field value.
ltDateSpecifies the exclusive upper bound date that the field value must be strictly less than.
geDateSpecifies the minimum inclusive date allowed for the field value.
gtDateSpecifies 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

NameTypeDescription
leOption< Date > = nullLess than or equal to constraint
ltOption< Date > = nullLess than constraint
geOption< Date > = nullGreater than or equal to constraint
gtOption< Date > = nullGreater than constraint
todayOption< NowConstraint > = nullConstraint 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

NameTypeDescription
leDateThe maximum allowable date, inclusive of the specified day.

Returns

TypeDescription
[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

NameTypeDescription
ltDateThe date that the value must be strictly earlier than.

Returns

TypeDescription
[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

NameTypeDescription
geDateThe minimum allowable date, inclusive of the specified day.

Returns

TypeDescription
[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

NameTypeDescription
gtDateThe date that the value must be strictly later than.

Returns

TypeDescription
[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

NameTypeDescription
today[NowConstraint](../datetime/nowconstraint.md?sid=validators_datetime_nowconstraint)The relative time constraint configuration used to compare the value against the current date.

Returns

TypeDescription
[DateConstraints](dateconstraints.md?sid=validators_date_dateconstraints)The updated DateConstraints instance with the relative 'now' constraint applied.