Type validators for the @reduct/component package.
The validators will, as the name states, validate as well as optionally transform the values into the requested types.
F.e. if you expect a Number
and the user passes in a String
containing a Number
, the validator will transform the value into a number. If the validation/transformation fails, the validator returns an Error object with a detailed message you can then throw
.
Will expect that the passed value is not undefined
or null
, and returns an Error
if the validation has failed.
Will expect that the passed value is not undefined
or null
, and always returns an object containing result
and value
key/value pairs.
Inherits the behavior of propTypes.any.isRequired
, but it expects that the value is a String
.
Inherits the behavior of propTypes.any.isOptional
, but it expects that the value is a String
.
Inherits the behavior of propTypes.any.isRequired
, but it expects that the value is either a Boolean
or a String
which can be converted to a Boolean
.
Inherits the behavior of propTypes.any.isOptional
, but it expects that the value is either a Boolean
or a String
which can be converted to a Boolean
.
Inherits the behavior of propTypes.any.isRequired
, but it expects that the value is either a Number
or a String
containing a Number
.
Inherits the behavior of propTypes.any.isOptional
, but it expects that the value is either a Number
or a String
containing a Number
.
Inherits the behavior of propTypes.any.isRequired
, but it expects that the value is either a valid Object
or a String
containing a JSON Object
.
Inherits the behavior of propTypes.any.isOptional
, but it expects that the value is either a valid Object
or a String
containing a JSON Object
.
In lieu of a formal styleguide, take care to maintain the existing coding style.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.