Using Default Values
Using default values in constraints
Overview
Basic Usage
class {
this.constraints = {
status: {
defaultValue: "active",
required: true,
inList: "active,inactive,pending"
},
createdDate: {
defaultValue: now(),
required: true,
type: "date"
},
priority: {
defaultValue: 5,
min: 1,
max: 10
}
};
}component {
this.constraints = {
status: {
defaultValue = "active",
required = true,
inList = "active,inactive,pending"
},
createdDate = {
defaultValue = now(),
required = true,
type = "date"
},
priority = {
defaultValue = 5,
min = 1,
max = 10
}
};
}When Defaults Are Applied
Practical Examples
Form with Default Status
Dynamic Default with Functions
API Validation with Defaults
Best Practices
1. Use for Optional Fields Only
2. Defaults Should Match Constraint Rules
3. Use Functions for Dynamic Defaults
4. Document Default Behavior
See Also
Last updated
Was this helpful?