Skip to content

Commit

Permalink
feat: Date ranger add rule
Browse files Browse the repository at this point in the history
  • Loading branch information
linhf123 committed Dec 9, 2024
1 parent 32afa12 commit d02e4cf
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/ui/src/DateRanger/demo/with-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,21 @@ export default () => {

return (
<Form form={form} onValuesChange={handleChange}>
<Form.Item name="range" initialValue={[dayjs('2021/01/01'), dayjs('2021/05/01')]}>
<Form.Item
name="range"
initialValue={[dayjs('2021/01/01'), dayjs('2021/05/01')]}
rules={[
{
validator(rule, value, callback) {
if (Math.abs(value[0].diff(value[1])) > 24 * 60 * 60 * 1000) {
callback('时间跨度不能超过一天');
} else {
callback();
}
},
},
]}
>
<DateRanger />
</Form.Item>
</Form>
Expand Down

0 comments on commit d02e4cf

Please sign in to comment.