1.3.6 • Published 5 years ago

cloud-panda-components v1.3.6

Weekly downloads
60
License
-
Repository
-
Last release
5 years ago

Cloud Panda Components

Description:

React Reusable Components.

first, install cloud panda components using node package manager(npm) #### > npm i cloud-panda-components

Validations

ValidationDescription
requiredValidates that the value must not be empty.
maxLengthIt is used to validate the maximum characters of the fields
minLengthIt is used to validate the minimum characters of the fields
isEmailValidates that a value is a valid email address.
isNumericValidates that the value is only a number.
alphaAlphabet only validation .
alphaNumValidates alpha numeric string value.
sameWithThe given field must match the value you passed under validation
isArrayThe value must be a valid array
file{maxSize}Validates the maximum filesize of the given file
file{extension}Validates the allowed file types of the given file
customCustom validation that uses regular expression/pattern

How to use Validations!

Example Code:

required

<Input validations={ { required: true } } /> -- Required

maxLength

<Input validations={ { maxLength: { value: 10 } } } /> -- Limit the maximum length of the input fields

minLength

<Input validations={ { minLength: { value: 6 } } } /> -- Minimum character length

isEmail

<Input validations={ { isEmail: true } } />

isNumeric

<Input validations={ { isNumeric: { value: 10 } } } /> -- Valid numbers only

isNumeric

<Input validations={ { alpha: true } } /> -- Alphabet only

sameWith

<Input validations={ { sameWith: { value: 'Pass123' } } } />

alphaNum

<Input validations={ { alphaNum: true } } /> -- For Alpha Numeric Validations

isArray

<Input validations={ { sameWith: {isArray: 'Mangos', 'Apple' } } } /> -- Valid array value only.

file{maxSize}

<Input validations={ { file: { maxSize: 2000 } } } /> -- Validate maximum size of file.

file{Extension}

<Input validations={ { file: { ext: 'docx|png|jpg|jpeg' } } } /> -- Validate allowed extensions for file.

custom

<Input validations={ { custom: { rules: /a-z0-9!#$%&'*+/=?^_`{|}~-+(?:.a-z0-9!#$%&'*+/=?^_`{|}~-+)@(?:a-z0-9(?:a-z0-9-a-z0-9)?.)+a-z0-9?/ } } } /> -- You can set your own validations with the use of regular expression

You can customize your own error message for each validations.

Example Code with custom error message

<Input validations={ { required: {message: 'This fields is empty'} } } /> <Input validations={ { maxLength: { value: 10, message: 'Maximum Length exceeded' } } } />

Multiple validations

<Input validations={ { required: {message: "This is a required field."}, isNumeric: {message: 'A valid number value is required.'} } } />

Note: Each validations has its own default error message, so it's okay to not set it if you want.

Props

PropsDescription
labelText of label, default: "No Label"
containerClassIt refers to the container of input and label, default: "form-group"
inputPropsrefering to the props of input e.g(placeholder, type)
labelPropsIt refers to the properties of label e.g(for, className)
validationsObject property that contains the validations
onChangeIt returns your function on onChange event of the input
validateWhen set to false, the input will not validate. default: true

Important Note:

required name properties on inputProps
1.3.6

5 years ago

1.3.5

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.0.13

5 years ago

1.0.11

5 years ago

1.2.10

5 years ago

1.0.10

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago