Closed riceyeh closed 2 years ago
validatedWith is used for validation of a field with other attributes beyond its value. I suggest to extend validatedWith to support nested property of field's value. The following is an example:
it('same oid', (done) => { const fields = [ "f1", "f2" ] const values = { f1: { oid: 1, name: 'Object 1' }, f2: { oid: 1, name: 'Object 1.1' } } const rules = { f1: 'different:f2', f2: 'different:f1' } const validatedWith = { f1: 'value.oid', f2: 'value.oid' } const related = { f1: ['f2'], f2: ['f1'] }
const $form = new Form({fields, values, rules, validatedWith, related}, { plugins, name: 'form'})
$form.validate({showError: true}).then(({isValid}) => { expect(isValid).to.be.false done() })
})
nice, I have published a new version!
validatedWith is used for validation of a field with other attributes beyond its value. I suggest to extend validatedWith to support nested property of field's value. The following is an example:
it('same oid', (done) => { const fields = [ "f1", "f2" ] const values = { f1: { oid: 1, name: 'Object 1' }, f2: { oid: 1, name: 'Object 1.1' } } const rules = { f1: 'different:f2', f2: 'different:f1' } const validatedWith = { f1: 'value.oid', f2: 'value.oid' } const related = { f1: ['f2'], f2: ['f1'] }
const $form = new Form({fields, values, rules, validatedWith, related}, { plugins, name: 'form'})
$form.validate({showError: true}).then(({isValid}) => { expect(isValid).to.be.false done() })
})