MCPcopy
hub / github.com/pocketbase/pocketbase / checkRange

Method checkRange

core/field_date.go:160–179  ·  view source on GitHub ↗
(min types.DateTime, max types.DateTime)

Source from the content-addressed store, hash-verified

158}
159
160func (f *DateField) checkRange(min types.DateTime, max types.DateTime) validation.RuleFunc {
161 return func(value any) error {
162 v, _ := value.(types.DateTime)
163 if v.IsZero() {
164 return nil // nothing to check
165 }
166
167 dr := validation.Date(types.DefaultDateLayout)
168
169 if !min.IsZero() {
170 dr.Min(min.Time())
171 }
172
173 if !max.IsZero() {
174 dr.Max(max.Time())
175 }
176
177 return dr.Validate(v.String())
178 }
179}

Callers 1

ValidateSettingsMethod · 0.95

Calls 4

IsZeroMethod · 0.80
TimeMethod · 0.80
ValidateMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected