Created
August 8, 2018 02:39
-
-
Save Jantho1990/aa231943fa730fe8cb6d8efa5058f161 to your computer and use it in GitHub Desktop.
StarRating Vue -- 9a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export let ratingIsValid = function (rating, minRating, maxRating) { | |
if (rating >= minRating && rating <= maxRating) return true | |
return false | |
} | |
export let valuesNotZeroOrLess = function (...values) { | |
let filteredValues = values.filter(value => value > 0) | |
return values.length === filteredValues.length | |
} | |
export let valuesNotNegative = function (...values) { | |
let filteredValues = values.filter(value => value >= 0) | |
return values.length === filteredValues.length | |
} | |
export let minLessThanMax = function (minRating, maxRating) { | |
return minRating < maxRating | |
} | |
export let valuesLessThanHardLimit = function (limit, ...values) { | |
let filteredValues = values.filter(value => value <= limit) | |
return values.length === filteredValues.length | |
} | |
export default function (rating, minRating, maxRating, starRatio, limit) { | |
return valuesLessThanHardLimit(limit, minRating, maxRating) && | |
valuesNotNegative(rating, minRating, maxRating) && | |
valuesNotZeroOrLess(starRatio) && | |
minLessThanMax(minRating, maxRating) && | |
ratingIsValid(rating, minRating, maxRating) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment