Skip to content

Commit

Permalink
Extracted isValid function
Browse files Browse the repository at this point in the history
  • Loading branch information
yuri-sakharov committed Nov 28, 2017
1 parent 2179f88 commit 7e10e30
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/utils/defaultFilterOptions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import stripDiacritics from './stripDiacritics';
import trim from './trim';

function isValid(value) {
return typeof (value) !== 'undefined' && value !== null && value !== '';
}

function filterOptions (options, filterValue, excludeOptions, props) {
if (props.ignoreAccents) {
filterValue = stripDiacritics(filterValue);
Expand All @@ -23,8 +27,8 @@ function filterOptions (options, filterValue, excludeOptions, props) {

var value = option[props.valueKey];
var label = option[props.labelKey];
var hasValue = typeof (value) !== 'undefined' && value !== null && value !== '';
var hasLabel = typeof (label) !== 'undefined' && label !== null && label !== '';
var hasValue = isValid(value);
var hasLabel = isValid(label);

if (!hasValue && !hasLabel) {
return false;
Expand Down

0 comments on commit 7e10e30

Please sign in to comment.