0.0.22 • Published 2 years ago

@fxi/mx_valid v0.0.22

Weekly downloads
15
License
MIT
Repository
github
Last release
2 years ago

MapX mx_valid

Simple validation tool for MapX specific values


Constants

Functions

regexUnsafeName

Test for special char : not allowed NOTES: if /g flag is set: inconsistant result: Regex.lastIndex is not reseted between calls, https://medium.com/@nikjohn/regex-test-returns-alternating-results-bd9a1ae42cdd

Kind: global constant

regexDataImg

Test if valide base64

Kind: global constant

isEmpty(item)

Test if entry is empty : empty array, empty string, etc.

Kind: global function

ParamTypeDescription
itemAnyitem to test

isNotEmpty()

Inverse isEmpty

Kind: global function

isBbox(item) ⇒ Boolean

Simple lat/lng bbox expected from source summary

Kind: global function
Returns: Boolean - Is lat/lng bbox object
Note: : currently match api/modules/template/sql/getSourceSummary_ext_sp.sql

ParamType
itemObject

isObject(item)

Test if entry is an object

Kind: global function

ParamType
itemObject

isView(item)

Test if it's a MapX view.

Kind: global function

ParamTypeDescription
itemObjectto test

isViewType(item, type, validator)

Test if it's a view of given type

Kind: global function

ParamTypeDescription
itemObjectto test
typeString | Arrayor array of types
validatorfunctionAdditionnal validator that must return boolean

isViewVt(item)

Test if it's a MapX view of type vt

Kind: global function

ParamTypeDescription
itemObjectto test

isViewRt(item)

Test if it's a MapX view of type rt

Kind: global function

ParamTypeDescription
itemObjectto test

isViewGj(item)

Test if it's a MapX view of type gj

Kind: global function

ParamTypeDescription
itemObjectto test

isViewEditable(item)

Test if it's a MapX view is editable

Kind: global function

ParamTypeDescription
itemObjectto test

isViewLocal(item)

Test if it's a MapX view is local

Kind: global function

ParamTypeDescription
itemObjectto test

isViewVtWithRules(item)

Test if view vt has style rules

Kind: global function

ParamTypeDescription
itemObjectto test

isViewVtWithStyleCustom(item)

Test if view vt has custom style

Kind: global function

ParamTypeDescription
itemObjectto test

isViewVtWithAttributeType(item, attribute)

Test if view vt has specific attribute type r

Kind: global function

ParamTypeDescription
itemObjectto test
attributeStringtype e.g. string;

isViewRtWithLegend(item)

Test if view rt has legend url

Kind: global function

ParamTypeDescription
itemObjectto test

isViewDownloadable(item)

Test if view is downloadable

Kind: global function

ParamTypeDescription
itemObjectto test

isViewRtWithTiles(item)

Test if view rt has tiles

Kind: global function

ParamTypeDescription
itemObjectto test

isViewDashboard(item)

Test if view has dashbaord

Kind: global function

ParamTypeDescription
itemObjectto test

isStory(item) ⇒ Boolean

Test if story map

Kind: global function

ParamTypeDescription
itemObjectItem to test

isArrayOf(arr, fun) ⇒ Boolean

Generic "array of" tester

Kind: global function

ParamTypeDescription
arrArrayArray
funfunctionFunction

isArrayOfViews(arr)

Test if is array of views object

Kind: global function

ParamTypeDescription
arrArrayArray to test

isViewWms(view) ⇒ Boolean

Test if a raster view has wms url

Kind: global function
Returns: Boolean - valid

ParamType
viewObject

isArrayOfViewsId(arr) ⇒ Boolean

Test if array of views id

Kind: global function

ParamTypeDescription
arrArrayArray of views id

isSortedArray(arr, desc)

Check if array is sorted

Kind: global function

ParamTypeDescription
arrArrayArray to test
descBooleanDescendent ?

isAgteB(a, b) ⇒ boolean

Compare value an return

Kind: global function

ParamTypeDescription
aAnyA value
bAnyB value

isAgtB(a, b) ⇒ Number

Compare a to b ( for sorting )

Kind: global function
Returns: Number - 1,-1 or 0

ParamTypeDescription
aAnyA value
bAnyB value

isRegExp(value) ⇒ Logical

Test for RegExp instance

Kind: global function
Returns: Logical - is RegExp instance

ParamType
valueAny

isProjectId(id) ⇒ Boolean

Test for valid project id

Kind: global function

ParamTypeDescription
idStringProject id to test

isSourceId(id) ⇒ boolean

Determines if the given ID is a valid MapX source ID.

A valid MapX source ID starts with 'mx', followed optionally by 'vector', and then by 5 to 7 segments of the pattern 'a-z0-9{1,6}'. The entire ID's length should be within the range of 10 to 50 characters.

Kind: global function
Returns: boolean - - Returns true if the ID matches the pattern and length constraints; otherwise, false.

ParamTypeDescription
idstringThe ID to test.

isArrayOfSourceId(arr)

Test if it's an array of MapX source id

Kind: global function

ParamTypeDescription
arrArrayArray of item to test

isViewId(id) ⇒ Boolean

Test for valid view id

Kind: global function

ParamTypeDescription
idStringView id to test

isProject(p) ⇒ Boolean

Test for valid project

Kind: global function

ParamTypeDescription
pObjectProject object

isProjectsArray(arr) ⇒ Boolean

Test for valid project array

Kind: global function

ParamTypeDescription
arrArrayArray of projects

isPromise(item)

Test for promise

Kind: global function

ParamTypeDescription
itemPromiseitem to test

isCanvas(item)

Test for canvas

Kind: global function

ParamTypeDescription
itemElementitem to test

isIconFont(item)

Test for fontawesome icon class

Kind: global function

ParamTypeDescription
itemElementitem to test

isArray(item)

Test if entry is an aray

Kind: global function

ParamTypeDescription
itemArrayarray

isTable(item)

Test if entry is an table (array of object)

Kind: global function

ParamTypeDescription
itemArrayarray

isJSON(String)

Test if entry is JSON

Kind: global function

ParamTypeDescription
StringStringto test

isStringifiable(item) ⇒ Boolean

Test if stringifiable

Kind: global function

ParamType
itemAny

isUndefined(item) ⇒ Boolean

Test if entry is undefined

Kind: global function

ParamType
itemAny

isNumeric(n)

Test if entry is numeric

Kind: global function

ParamTypeDescription
nString | Numberstring or number to test

isBoolean(b)

Test if entry is boolean

Kind: global function

ParamTypeDescription
bBooleanboolean to test

isBooleanCoercible(b) ⇒ Boolean

Test for a loose boolean type, e.g. from csv...

Kind: global function

ParamTypeDescription
bBooleanboolean to test

isMap(map)

Test if is map

Kind: global function

ParamTypeDescription
mapObjectMap object

isLngLatInsideBounds(lngLat, bounds) ⇒ boolean

Checks if a LngLat coordinate is inside the given LngLatBounds object.

Kind: global function
Returns: boolean - - Returns true if the LngLat coordinate is inside the LngLatBounds, otherwise false.

ParamTypeDescription
lngLatmapboxgl.LngLatThe LngLat coordinate to check.
boundsmapboxgl.LngLatBoundsThe LngLatBounds object to check against.

isBoundsInsideBounds(bounds_test, bounds) ⇒ boolean

Checks if a LngLatBounds object is inside another LngLatBounds

Kind: global function
Returns: boolean - - Returns true if the LngLatBounds object is inside the current bounds of getMaxBounds, otherwise false.

ParamTypeDescription
bounds_testmapboxgl.LngLatBoundsThe LngLatBounds object to check.
boundsmapboxgl.LngLatBoundsThe LngLatBounds object to compare t.

isStringRange(str,, min, max)

Test if entry is string and have the correct number of characters

Kind: global function

ParamTypeDescription
str,Stringcharacter to test
minNumberMinumum number of characters. Default 0.
maxNumberMaximum number of characters. Default Infinity.

isSafe(x)

Test if input value is "safe". Use server side -> avoid unwanted stuff for db : columns, values, .. when prepared queries are not possible.

Kind: global function

ParamTypeDescription
xAnyAny

isSafeName(x)

Test if input is "safe" for naming db table, column.

Kind: global function

ParamTypeDescription
xAnyAny

isValidType(type, group)

Quick type checker by group eg. image

Kind: global function

ParamTypeDescription
typeStringType to test
groupStringGroup : image, ... NOTE: to be completed

isHTML(n)

Test if string contain HTML

Kind: global function
Note: https://stackoverflow.com/questions/15458876/check-if-a-string-is-html-or-not#answer-36773193

ParamTypeDescription
nStringstring to test

isEmail(email)

Test if entry is an email

Kind: global function

ParamType
emailString

isString(str)

Test if entry is string

Kind: global function

ParamTypeDescription
strStringstring to test

isFunction(fun)

Test if entry is function

Kind: global function

ParamTypeDescription
funfunctionFunction to test

isElement(obj)

Check if an object is a html element

Kind: global function

ParamTypeDescription
objObjectobject to test

isEqual(x, y) ⇒ Boolean

Test for object equality

Kind: global function
Returns: Boolean - Are those object equal ?
Note: asnwer by Ebrahim Byagowi at https://stackoverflow.com/questions/201183/how-to-determine-equality-for-two-javascript-objects

ParamTypeDescription
xObjectFirst object to compare
yObjectSecond object to compare

isEqualNoType(a, b) ⇒ boolean

Compares two values for equivalence, ignoring types and leading/trailing whitespace.

Kind: global function
Returns: boolean - - Returns true if the normalized forms of the two values are equivalent, false otherwise.

ParamTypeDescription
a*The first value to compare.
b*The second value to compare.

normalizeValue(value) ⇒ string | number

Normalizes a value by converting it to a string, trimming whitespace, and converting it to a number if it represents a valid number.

Kind: global function
Returns: string | number - - The normalized value.

ParamTypeDescription
value*The value to normalize.

isUrl(url) ⇒ Boolean

Validate url

Kind: global function
Note: new version uses Url & tryCatch
Note: https://stackoverflow.com/questions/8667070/javascript-regular-expression-to-validate-url
Note: https://mathiasbynens.be/demo/url-regex

ParamTypeDescription
urlStringto test

isUrlHttps(url) ⇒ Boolean

Validate url with https

Kind: global function

ParamTypeDescription
urlStringto test

isUrlValidWms(url, opt) ⇒ Boolean

Check if it's expected url for wms end point.

Kind: global function
Returns: Boolean - valid

ParamTypeDescription
urlStringto test
optObjectoptions
opt.layersBooleanShould the url contains layers param ?

isDateStringRegex(date)

Validate date string

Kind: global function

ParamTypeDescription
dateNumberto validate

isDateString(date)

Validate date string

Kind: global function

ParamTypeDescription
dateString | Numberto validate

isDate(date)

Validate date object

Kind: global function

ParamTypeDescription
dateDateto validate

© 2019-present unepgrid.ch

0.0.22

2 years ago

0.0.21

2 years ago

0.0.20

3 years ago

0.0.18

3 years ago

0.0.19

3 years ago

0.0.12

3 years ago

0.0.13

3 years ago

0.0.15

3 years ago

0.0.16

3 years ago

0.0.17

3 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.5

5 years ago

0.0.6

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago