forked from jquense/yup
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstratch.js
More file actions
26 lines (22 loc) · 695 Bytes
/
stratch.js
File metadata and controls
26 lines (22 loc) · 695 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
var yup = require('yup')
var NoteSchema = yup.object()
.camelCase()
.shape({
noteID: yup.number().min(1).default(0),
notes: yup.string().required(),
subRBType: yup.string(),
rBType: yup.string(),
subRBTypeID: yup.number(),
rBTypeID: yup.number(),
noteDate: yup.date()
.when('rBType', { is: 0, then: })
.when('subRBTypeID', val => val === 1 ? this.required() : this
})
})
.text('date range', 'Date must be between ${start} and ${end}', function(){
})
.text({ message: 'date', params: { start, end }}, function(){
})
.when('subRBTypeID')
.is(0).then('noteDate')
.is( v => v >= 0 ).then('noteDate')