Skip to content

Commit

Permalink
Rename valueIsPresent to isValuePresent
Browse files Browse the repository at this point in the history
  • Loading branch information
tagliala committed Sep 26, 2021
1 parent 556df2d commit 1aba302
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 38 deletions.
16 changes: 8 additions & 8 deletions dist/client-side-validations.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}
};
Expand Down
16 changes: 8 additions & 8 deletions dist/client-side-validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
6 changes: 3 additions & 3 deletions src/validators/local/absence_presence.js
Original file line number Diff line number Diff line change
@@ -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
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/validators/local/exclusion_inclusion.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { arrayHasValue, valueIsPresent } from '../../helpers.js'
import { arrayHasValue, isValuePresent } from '../../helpers.js'

const isInList = (value, otherValues) => {
const normalizedOtherValues = []
Expand All @@ -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
}

Expand All @@ -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
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/validators/local/format.js
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions src/validators/local/length.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { valueIsPresent } from '../../helpers.js'
import { isValuePresent } from '../../helpers.js'

const VALIDATIONS = {
is: (a, b) => {
Expand Down Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions src/validators/local/numericality.js
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down Expand Up @@ -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
}

Expand Down
16 changes: 8 additions & 8 deletions vendor/assets/javascripts/rails.validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}
};
Expand Down

0 comments on commit 1aba302

Please sign in to comment.