4 Forms

4 Forms

  • Getting Started
  • API
  • Github
  • Help

›API Reference

Introduction

  • Getting Started
  • Installation
  • Motivation
  • Examples

Guides

  • Intro
  • Field
  • Schema
  • Nested schema
  • Related Field

API Reference

  • API Reference
  • Field
  • Schema
  • When
  • Rules

    • Generic
    • String
    • Number
    • Boolean
    • Array
    • Object
    • Iterator

Object

Rules for object validation.

Methods

  • hasKey(key, [options])
  • hasValue(value, [options])

Reference

hasKey(key, [options])

checks if object field has a key given as argument.

Optionally, you can provide a options object that can hold message and constraints.

Example

import { Field } from "v4f";

const field = Field()
    .object()
    .hasKey("username");

field.validate({ username: "x", a: 1 }); // true
field.validate({ a: 1 }); // false

hasValue(value, [options])

checks if object field has the value given as argument.

Optionally, you can provide a options object that can hold message and constraints.

NOTE : hasValue use the strict operator === for check.

Example

import { Field } from "v4f";

const field = Field()
    .object()
    .hasValue(4);

field.validate({ a: 4, b: 3 }); // true
field.validate({ a: 3, b: 2 }); // false
← ArrayIterator →
  • Methods
  • Reference
    • hasKey(key, [options])
    • hasValue(value, [options])
4 Forms
Docs
Getting StartedGuidesAPI Reference
Community
Stack OverflowProject ChatTwitter
More
GitHub
Copyright © 2019 Soufiane Nassih