#Color field validation not showing

6 messages · Page 1 of 1 (latest)

orchid sable
edgy sentinelBOT
short veldt
#

Hey @orchid sable sorry to hear you're having issues. @hushed bloom you mind jumping in here to help?

hushed bloom
#

Hey @orchid sable. The thing to note custom field validation functions is that they override the payload field default validation methods. If you want call the defaults the recommended way is to import from 'payload' the field validation for the type that best fits your custom field and return that call instead of the result you would normally return. Does that make sense?
Alternatively you can always just copy the validation required logic from the text function which normally looks like this:

  if (required) {
    if (typeof value !== 'string' || value?.length === 0) {
      return t('validation:required')
    }
  }
orchid sable
hushed bloom