solidity-validator.js
A library of string validators.
Installation and Usage
npm install solidity-validator
Function
Validator | Description |
---|---|
isAddress(str) | check if a string is a address. |
isBoolean(str) | check if a string is a boolean. |
isInt8(str) | check if a string is a int8. |
isUint8(str) | check if a string is a uint8. |
isBytesN(str) | check if a string is a BytesN, N:1-32 |
isByte(str) | check if a string is a Bytes1 |
isBytes(str) | check if a string is a Byte1 ~ Byte32 |
isValid(type, str) | check if a string is match the type |
getRange(type) | get type MIN and MAX range |
getMessage(type, str) | get valid message |
Example
var validator = ; validator; // truevalidator; // false validator; // truevalidator; // truevalidator; // falsevalidator; // false validator; // truevalidator; // truevalidator; // false validator; // truevalidator; // truevalidator; // falsevalidator; // falsevalidator; // false validator; // truevalidator; // truevalidator; // falsevalidator; // falsevalidator; // truevalidator; // truevalidator; // falsevalidator; // false validator; // truevalidator; // truevalidator; // falsevalidator; // false validator; // truevalidator; // truevalidator; // falsevalidator; // false validator; // truevalidator; // falsevalidator; // false validator;validator;validator; // The value is an illegal range.validator; // The value is an illegal range.validator; // The value is not a boolean. validatorvalidatorvalidator validator; // The value is not a valid address.validator; // The value is not a valid bytes.
validator; /* === output ==={ MIN: -128, MAX: 127}*/
Tests
Tests are using mocha, to run the tests use:
npm test
Maintainers
- alincode - AILIN LIOU (author)
License
MIT © alincode