MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / minMaxValidator

Function minMaxValidator

web/pgadmin/static/js/validators.js:15–27  ·  view source on GitHub ↗
(label, value, minValue, maxValue)

Source from the content-addressed store, hash-verified

13
14/* Validate value for min max range */
15export function minMaxValidator(label, value, minValue, maxValue) {
16 if((_.isUndefined(value) || _.isNull(value) || String(value) === ''))
17 return null;
18
19 if((!_.isUndefined(minValue) && isNaN(minValue)) || (!_.isUndefined(maxValue) && isNaN(maxValue))) {
20 return pgAdmin.Browser.messages.INVALID_MIN_MAX;
21 } else if (!_.isUndefined(minValue) && (value < minValue || value === '-')) {
22 return sprintf(pgAdmin.Browser.messages.MUST_GR_EQ, label, minValue);
23 } else if (!_.isUndefined(maxValue) && value > maxValue) {
24 return sprintf(pgAdmin.Browser.messages.MUST_LESS_EQ, label, maxValue);
25 }
26 return null;
27}
28
29/* Validate value to check if it is a number */
30export function numberValidator(label, value) {

Callers 2

PaginationInputsFunction · 0.90
validateSchemaFunction · 0.90

Calls 1

sprintfFunction · 0.90

Tested by

no test coverage detected