![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
indicative-utils
Advanced tools
Usage • Why? • Features • Examples • Documentation
Handy utility functions used by other Indicative packages. If you are extending Indicative to add your own rules, then you may find some handy utilities in this package.
Install the package from npm
npm i indicative-utils
and then import the functions you need
import { cast, ensureLength, skippable, patchValue } from 'indicative-utils'
Following is the usage for individual methods
cast(value: any, toType: string, errorMessage?: string): output
Casts value to a given data type. Returns null
when unable to cast value.
cast('10', 'number', 'Optional error message to raise exception')
'number' | 'date' | 'string' | 'integer' | 'boolean'
errorMessage
is defined and unable to cast value.ensureLength (args: any[], errorMessage: string, minLength = 1): void
Raise an exception when the length of args
is less than the defined minLength
.
ensureLength(['foo', 'bar'], 'Array must have minimum of 3 items', 3)
patchValue (data: any, field: string, fieldValue: any, root: DataRoot)
This method is used by validation functions that wants to mutate/cast the input value and set it back on the source object. It is recommended to use this method vs doing it manually, since it handles edge cases.
The DataRoot
value is available inside all validation functions, you must pass it as it is.
patchValue({ age: '10' }, 'age', 10, {})
skippable(value: any, fieldName: string, config: { existyStrict: boolean })
Again, this method is used by validation functions to know if the value of field must be skipped from validation or not.
Indicative by default assumes all fields as optional and one must use required
rule for required fields. Which means that validation rules like email
, date
and so on must skip undefined
or null
values based upon the user config. This method does that check for you.
// read field value inside validation function
const fieldValue = data[field]
skippable(fieldValue, field, config)
FAQs
Reusable utilities for indicative validation library
The npm package indicative-utils receives a total of 7,906 weekly downloads. As such, indicative-utils popularity was classified as popular.
We found that indicative-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.