jarb-final-form
Version:
Validating forms through JaRB.
24 lines (23 loc) • 1.18 kB
TypeScript
import { FieldType, Constraints, FieldConstraints } from './models';
/**
* Finds the most specific <input> type for the types parameter. For example if
* types is ['email', 'text'] the function returns 'email' because 'email'
* is the most specific input type. If nothing is found returns 'text'.
*
* @param {Array<string>} The types you want the closest type for.
* @return {FieldType} The closest <input> type, based on the types parameter.
*/
export declare function mostSpecificInputTypeFor(types: FieldType[]): FieldType;
/**
* Finds the FieldConstraints rules for a specific validator in the
* Constraints object.
*
* If no constraints can be found for a validator the boolean false
* is returned.
*
* @param {validator} 'validator' is a string with the format: 'Class.field' for example: 'User.age'
* @param {Constraints} The constraints to find the validator in.
* @throws {error} When the validator doesn't match the format 'className.fieldName'.
* @returns {FieldConstraints | false} The constraints for the specific field
*/
export declare function getFieldConstraintsFor(validator: string, constraints: Constraints): FieldConstraints | false;