diff --git a/addon/index.js b/addon/index.js index 8818f03..9293d04 100644 --- a/addon/index.js +++ b/addon/index.js @@ -92,9 +92,15 @@ export default function validationState(VALIDATOR_FNS) { * @param {object} context - the options hash passed along to ember-validators * @returns {function<*, MessageBuilder>: [isValid: boolean, message?: string]} */ -export function validate(eventName, context) { +export function validate(eventName, context, model, attribute) { return function (value, messageSvc) { - const validOrContext = _validate(eventName, value, context); + const validOrContext = _validate( + eventName, + value, + context, + model, + attribute + ); if (typeof validOrContext === 'boolean') { return [true]; diff --git a/index.d.ts b/index.d.ts index a6abed9..d8d563f 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,21 +1,21 @@ type Validators = Record; -type AttributeValidation = { +interface AttributeValidation { messages: string[]; isValid: boolean; -}; +} type AttrsType = { [P in keyof T]: AttributeValidation; }; -export type ValidationState = { +export interface ValidationState { isValid: boolean; attrs: AttrsType; -}; +} -export function validate(any, any): any; +export function validate(validatorName: any, context: any, model?: any, attribute?: string): any; export default function validationState( validators: Validators | ((ctx: any) => Validators) -): PropertyDescriptor>; +): (target: T, key: keyof T) => void;