From 1aba302d72a35da63f2c54b041a655d06d98df38 Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Sun, 26 Sep 2021 19:58:40 +0200 Subject: [PATCH] Rename valueIsPresent to isValuePresent --- dist/client-side-validations.esm.js | 16 ++++++++-------- dist/client-side-validations.js | 16 ++++++++-------- src/helpers.js | 4 ++-- src/validators/local/absence_presence.js | 6 +++--- src/validators/local/exclusion_inclusion.js | 6 +++--- src/validators/local/format.js | 4 ++-- src/validators/local/length.js | 4 ++-- src/validators/local/numericality.js | 4 ++-- vendor/assets/javascripts/rails.validations.js | 16 ++++++++-------- 9 files changed, 38 insertions(+), 38 deletions(-) diff --git a/dist/client-side-validations.esm.js b/dist/client-side-validations.esm.js index 8dca2e890..9f78e3b7b 100644 --- a/dist/client-side-validations.esm.js +++ b/dist/client-side-validations.esm.js @@ -267,17 +267,17 @@ var arrayHasValue = function arrayHasValue(value, otherValues) { return false; }; -var valueIsPresent = function valueIsPresent(value) { +var isValuePresent = function isValuePresent(value) { return !/^\s*$/.test(value || ''); }; var absenceLocalValidator = function absenceLocalValidator(element, options) { - if (valueIsPresent(element.val())) { + if (isValuePresent(element.val())) { return options.message; } }; var presenceLocalValidator = function presenceLocalValidator(element, options) { - if (!valueIsPresent(element.val())) { + if (!isValuePresent(element.val())) { return options.message; } }; @@ -327,7 +327,7 @@ var hasValidFormat = function hasValidFormat(value, withOptions, withoutOptions) var formatLocalValidator = function formatLocalValidator(element, options) { var value = element.val(); - if (options.allow_blank && !valueIsPresent(value)) { + if (options.allow_blank && !isValuePresent(value)) { return; } @@ -416,7 +416,7 @@ var runValidations$1 = function runValidations(formattedValue, $form, options) { var numericalityLocalValidator = function numericalityLocalValidator(element, options) { var value = element.val(); - if (options.allow_blank && !valueIsPresent(value)) { + if (options.allow_blank && !isValuePresent(value)) { return; } @@ -452,7 +452,7 @@ var runValidations = function runValidations(valueLength, options) { var lengthLocalValidator = function lengthLocalValidator(element, options) { var value = element.val(); - if (options.allow_blank && !valueIsPresent(value)) { + if (options.allow_blank && !isValuePresent(value)) { return; } @@ -474,7 +474,7 @@ var isInRange = function isInRange(value, range) { }; var isIncluded = function isIncluded(value, options, allowBlank) { - if ((options.allow_blank && !valueIsPresent(value)) === allowBlank) { + if ((options.allow_blank && !isValuePresent(value)) === allowBlank) { return true; } @@ -484,7 +484,7 @@ var isIncluded = function isIncluded(value, options, allowBlank) { var exclusionLocalValidator = function exclusionLocalValidator(element, options) { var value = element.val(); - if (isIncluded(value, options, false) || !options.allow_blank && !valueIsPresent(value)) { + if (isIncluded(value, options, false) || !options.allow_blank && !isValuePresent(value)) { return options.message; } }; diff --git a/dist/client-side-validations.js b/dist/client-side-validations.js index de8ded4d5..de3d3d4a8 100644 --- a/dist/client-side-validations.js +++ b/dist/client-side-validations.js @@ -275,17 +275,17 @@ return false; }; - var valueIsPresent = function valueIsPresent(value) { + var isValuePresent = function isValuePresent(value) { return !/^\s*$/.test(value || ''); }; var absenceLocalValidator = function absenceLocalValidator(element, options) { - if (valueIsPresent(element.val())) { + if (isValuePresent(element.val())) { return options.message; } }; var presenceLocalValidator = function presenceLocalValidator(element, options) { - if (!valueIsPresent(element.val())) { + if (!isValuePresent(element.val())) { return options.message; } }; @@ -335,7 +335,7 @@ var formatLocalValidator = function formatLocalValidator(element, options) { var value = element.val(); - if (options.allow_blank && !valueIsPresent(value)) { + if (options.allow_blank && !isValuePresent(value)) { return; } @@ -424,7 +424,7 @@ var numericalityLocalValidator = function numericalityLocalValidator(element, options) { var value = element.val(); - if (options.allow_blank && !valueIsPresent(value)) { + if (options.allow_blank && !isValuePresent(value)) { return; } @@ -460,7 +460,7 @@ var lengthLocalValidator = function lengthLocalValidator(element, options) { var value = element.val(); - if (options.allow_blank && !valueIsPresent(value)) { + if (options.allow_blank && !isValuePresent(value)) { return; } @@ -482,7 +482,7 @@ }; var isIncluded = function isIncluded(value, options, allowBlank) { - if ((options.allow_blank && !valueIsPresent(value)) === allowBlank) { + if ((options.allow_blank && !isValuePresent(value)) === allowBlank) { return true; } @@ -492,7 +492,7 @@ var exclusionLocalValidator = function exclusionLocalValidator(element, options) { var value = element.val(); - if (isIncluded(value, options, false) || !options.allow_blank && !valueIsPresent(value)) { + if (isIncluded(value, options, false) || !options.allow_blank && !isValuePresent(value)) { return options.message; } }; diff --git a/src/helpers.js b/src/helpers.js index 9c02094c6..f135535b7 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -8,11 +8,11 @@ export const arrayHasValue = (value, otherValues) => { return false } -export const valueIsPresent = (value) => { +export const isValuePresent = (value) => { return !/^\s*$/.test(value || '') } export default { arrayHasValue, - valueIsPresent + isValuePresent } diff --git a/src/validators/local/absence_presence.js b/src/validators/local/absence_presence.js index aabd8b6d0..e75a65b65 100644 --- a/src/validators/local/absence_presence.js +++ b/src/validators/local/absence_presence.js @@ -1,13 +1,13 @@ -import { valueIsPresent } from '../../helpers.js' +import { isValuePresent } from '../../helpers.js' export const absenceLocalValidator = (element, options) => { - if (valueIsPresent(element.val())) { + if (isValuePresent(element.val())) { return options.message } } export const presenceLocalValidator = (element, options) => { - if (!valueIsPresent(element.val())) { + if (!isValuePresent(element.val())) { return options.message } } diff --git a/src/validators/local/exclusion_inclusion.js b/src/validators/local/exclusion_inclusion.js index 4909c3255..bed661438 100644 --- a/src/validators/local/exclusion_inclusion.js +++ b/src/validators/local/exclusion_inclusion.js @@ -1,4 +1,4 @@ -import { arrayHasValue, valueIsPresent } from '../../helpers.js' +import { arrayHasValue, isValuePresent } from '../../helpers.js' const isInList = (value, otherValues) => { const normalizedOtherValues = [] @@ -15,7 +15,7 @@ const isInRange = (value, range) => { } const isIncluded = (value, options, allowBlank) => { - if ((options.allow_blank && !valueIsPresent(value)) === allowBlank) { + if ((options.allow_blank && !isValuePresent(value)) === allowBlank) { return true } @@ -25,7 +25,7 @@ const isIncluded = (value, options, allowBlank) => { export const exclusionLocalValidator = (element, options) => { const value = element.val() - if (isIncluded(value, options, false) || (!options.allow_blank && !valueIsPresent(value))) { + if (isIncluded(value, options, false) || (!options.allow_blank && !isValuePresent(value))) { return options.message } } diff --git a/src/validators/local/format.js b/src/validators/local/format.js index 8126f5c5e..74e801914 100644 --- a/src/validators/local/format.js +++ b/src/validators/local/format.js @@ -1,4 +1,4 @@ -import { valueIsPresent } from '../../helpers.js' +import { isValuePresent } from '../../helpers.js' const isMatching = (value, regExpOptions) => { return new RegExp(regExpOptions.source, regExpOptions.options).test(value) @@ -11,7 +11,7 @@ const hasValidFormat = (value, withOptions, withoutOptions) => { export const formatLocalValidator = (element, options) => { const value = element.val() - if (options.allow_blank && !valueIsPresent(value)) { + if (options.allow_blank && !isValuePresent(value)) { return } diff --git a/src/validators/local/length.js b/src/validators/local/length.js index 993549db4..4becdbafb 100644 --- a/src/validators/local/length.js +++ b/src/validators/local/length.js @@ -1,4 +1,4 @@ -import { valueIsPresent } from '../../helpers.js' +import { isValuePresent } from '../../helpers.js' const VALIDATIONS = { is: (a, b) => { @@ -26,7 +26,7 @@ const runValidations = (valueLength, options) => { export const lengthLocalValidator = (element, options) => { const value = element.val() - if (options.allow_blank && !valueIsPresent(value)) { + if (options.allow_blank && !isValuePresent(value)) { return } diff --git a/src/validators/local/numericality.js b/src/validators/local/numericality.js index a8c069f82..6af708aed 100644 --- a/src/validators/local/numericality.js +++ b/src/validators/local/numericality.js @@ -1,6 +1,6 @@ import $ from 'jquery' import ClientSideValidations from '../../ClientSideValidations' -import { valueIsPresent } from '../../helpers.js' +import { isValuePresent } from '../../helpers.js' const VALIDATIONS = { even: (a) => { @@ -83,7 +83,7 @@ const runValidations = (formattedValue, $form, options) => { export const numericalityLocalValidator = (element, options) => { const value = element.val() - if (options.allow_blank && !valueIsPresent(value)) { + if (options.allow_blank && !isValuePresent(value)) { return } diff --git a/vendor/assets/javascripts/rails.validations.js b/vendor/assets/javascripts/rails.validations.js index de8ded4d5..de3d3d4a8 100644 --- a/vendor/assets/javascripts/rails.validations.js +++ b/vendor/assets/javascripts/rails.validations.js @@ -275,17 +275,17 @@ return false; }; - var valueIsPresent = function valueIsPresent(value) { + var isValuePresent = function isValuePresent(value) { return !/^\s*$/.test(value || ''); }; var absenceLocalValidator = function absenceLocalValidator(element, options) { - if (valueIsPresent(element.val())) { + if (isValuePresent(element.val())) { return options.message; } }; var presenceLocalValidator = function presenceLocalValidator(element, options) { - if (!valueIsPresent(element.val())) { + if (!isValuePresent(element.val())) { return options.message; } }; @@ -335,7 +335,7 @@ var formatLocalValidator = function formatLocalValidator(element, options) { var value = element.val(); - if (options.allow_blank && !valueIsPresent(value)) { + if (options.allow_blank && !isValuePresent(value)) { return; } @@ -424,7 +424,7 @@ var numericalityLocalValidator = function numericalityLocalValidator(element, options) { var value = element.val(); - if (options.allow_blank && !valueIsPresent(value)) { + if (options.allow_blank && !isValuePresent(value)) { return; } @@ -460,7 +460,7 @@ var lengthLocalValidator = function lengthLocalValidator(element, options) { var value = element.val(); - if (options.allow_blank && !valueIsPresent(value)) { + if (options.allow_blank && !isValuePresent(value)) { return; } @@ -482,7 +482,7 @@ }; var isIncluded = function isIncluded(value, options, allowBlank) { - if ((options.allow_blank && !valueIsPresent(value)) === allowBlank) { + if ((options.allow_blank && !isValuePresent(value)) === allowBlank) { return true; } @@ -492,7 +492,7 @@ var exclusionLocalValidator = function exclusionLocalValidator(element, options) { var value = element.val(); - if (isIncluded(value, options, false) || !options.allow_blank && !valueIsPresent(value)) { + if (isIncluded(value, options, false) || !options.allow_blank && !isValuePresent(value)) { return options.message; } };