From 6a00c4ac08dedaffc969d140f1402f64127b78a9 Mon Sep 17 00:00:00 2001 From: zamarawka Date: Thu, 2 Jun 2022 07:45:09 +0300 Subject: [PATCH] Update readme --- README.md | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/README.md b/README.md index de4646a..ed330f3 100644 --- a/README.md +++ b/README.md @@ -256,6 +256,124 @@ const rules = { }; ``` +### requiredWith + +Check value required if other value is positive + +```tsx +// Negative cases +const data = { + other: 1, + some: false, +}; + +// Positive cases +const data = { + other: 1, + some: true, +}; + +const data = { + other: 0, + some: false, +}; + +// Example +const rules = { + some: requiredWith(data.other), +}; +``` + +### requiredWithAll + +Check value required if every of other values are positive + +```tsx +// Negative cases +const data = { + other: 1, + foo: 'some', + some: false, +}; + +// Positive cases +const data = { + other: 1, + foo: 'some', + some: true, +}; + +const data = { + other: 0, + foo: 'some', // or '' + some: false, +}; + +// Example +const rules = { + some: requiredWithAll([data.other, data.foo, true]), +}; +``` + +### requiredWithout + +Check value required if other value is negative + +```tsx +// Negative cases +const data = { + other: 0, + some: false, +}; + +// Positive cases +const data = { + other: 0, + some: true, +}; + +const data = { + other: 1, + some: false, +}; + +// Example +const rules = { + some: requiredWithout(data.other), +}; +``` + +### requiredWithoutAll + +Check value required if every of other values are negative + +```tsx +// Negative cases +const data = { + other: 0, + foo: '', + some: false, +}; + +// Positive cases +const data = { + other: 0, + foo: '', + some: true, +}; + +const data = { + other: 0, // or 1 + foo: 'some', + some: false, +}; + +// Example +const rules = { + some: requiredWithoutAll([data.other, data.foo, false]), +}; +``` + ### same Check value are same