Get valid data by condtion.
yarn add @jswork/next-get-valid
import '@jswork/next-get-valid';
const data = {
name: 'xiaoming',
age: 18,
email: ''
};
const isValidEmail = (value) => {
return value.indexOf('@') > -1;
};
const res = nx.getValid(data, 'email', 'example@email', isValidEmail);
// res -> 'example@email'
Code released under the MIT license.